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 trialDon-Alex Antoine
8,207 PointsMy image doesn't change to a new image everytime i refresh the page
<img src="https://placeimg.com/200/200/tech" alt="Tech">
The image is not changing into a new image every time I refresh the page. This is the code I used.
4 Answers
Steven Parker
231,236 PointsYour browser is probably caching the image as an efficiency measure. Most browsers have a separate refresh function that disregards the cache you could try, or a configuration option to clear the cache.
You could also add a small JavaScript component to add a random query string to the URL to prevent caching. I provided some sample code for this in an answer to a previous similar question.
Chintan Ray
Full Stack JavaScript Techdegree Student 12,309 PointsYou can also simply hold down the shift key while refreshing the page. It works for me. I am not familiar with JavaScript, but this is a crude way of clearing the cached images.
Don-Alex Antoine
8,207 PointsYou are right. it is caching the images as an efficiency measure.
Parminder Kaur
4,188 PointsI was facing the same problem, and pressing shift key along with the refresh button worked for me. Thanks!