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 trial

HTML Introduction to HTML and CSS (2016) HTML: The Structural Foundation of Web Pages and Applications Image Tags

Placehold

<header> <img src="http://placeimg.com/400/400/people" alt="Drawing of Jane Smith" class="profile-image"> <h1 class="tag name">Hello, Iā€™m Andreia.</h1> <p class="tag location">My home is wigan,England.</p> </header> This doesn't make the image change every time I refresh the browser.

1 Answer

Steven Parker
Steven Parker
229,732 Points

Your browser is most likely displaying a cached image instead of fetching a new one. Depending on the browser, there may be a special way to refresh without cache or you may be able to perform a separate funciton to delete cached images and pages.

You can also add a fake query string to your image URL to prevent the browser from using the cached version with a line of JavaScript like this:

document.querySelector("img").src += "?nocache=" + Math.random();

Note that this particular version only affects the first image on the page.