Skrevet av Emne: AJAX: HTML reloads but images do not refresh  (Lest 4963 ganger)

ATC

  • Gjest
AJAX: HTML reloads but images do not refresh
« på: 02. April 2009, 21:19 pm »
  • [applaud]0
  • [smite]0
  • 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.



    ATC

    • Gjest
    [Solved] AJAX: HTML reloads but images do not refresh
    « Svar #1 på: 02. April 2009, 21:19 pm »
  • [applaud]0
  • [smite]0
  • 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.