Forums.ATC.no

Teknisk => Generelt teknisk => Emne startet av: ATC på 02. April 2009, 21:19 pm

Tittel: AJAX: HTML reloads but images do not refresh
Skrevet av: ATC02. April 2009, 21:19 pm
When refreshing or updating part of a web page using AJAX (or similar techniques) some browsers will use cached images without checking for updates, even if the HTTP header indicates the image has expired.
Tittel: [Solved] AJAX: HTML reloads but images do not refresh
Skrevet av: ATC02. April 2009, 21:19 pm
Add the current unixtime to the image file name like so:


The web server will interpret this as an encoded parameter and thrown it away when serving images. (If you are using parameters for your images, then I assume you know what you're doing. Maybe you're using an auto-thumbnailer or something)

Anyway, each HTML update will contain a slightly different image URL. defeating the (flawed) browser cache mechanism and cause the image to reload properly.