Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCASEY KELLEHER
Courses Plus Student 658 Pointsthe copy and paste function of the picimg is not changing the pic everytime i refresh the worksheet, it stays the same??
When copy and pasting the picimg file into the html code it is supposed to generate a new picture every time you refresh but its staying the same??
1 Answer
Steven Parker
231,261 PointsYour browser may be displaying a cached image instead of fetching a new one.
You can add a fake query string to your image URL to prevent the browser from using the cached version with a line of JavaScript:
document.querySelector("img").src += "?nocache=" + Math.random();
Note that this particular script will only work for the first image on the page, you may need a more specific selector otherwise.