sysKin
10th December 2004, 12:53
Hi ppl,
For a couple of days (I think some time after forum server switch), I'm seeing forum images reloading every time I visit.
Using great Live HTTP Headers (http://livehttpheaders.mozdev.org/) extension I can see what's going on.
1. There is no default time-to-live for images, such as "Cache-Control: max-age [seconds]" header. This would make browsers use cached image without even checking if updated version exists (for seconds secs) and I'm sure old forum did that. At least 86400 seconds (24 hours) would be good, perhaps 7 times more would be better (maybe not for avatars).
2. Server sends Last-Modified and E-Tag headers which are used to identify if image changed. Therefore, next time an image is loaded, browser sends If-Modified-Since and If-None-Match headers, and only expects to recieve an image (200 OK) if new version is available. Otherwise, it expects 304 Not Modified and can use the cached version.
Server's response is always 200 OK and then the image still has the same modification date and the same e-tag...
http://homepages.ihug.com.au/~syskin/http.png
For a couple of days (I think some time after forum server switch), I'm seeing forum images reloading every time I visit.
Using great Live HTTP Headers (http://livehttpheaders.mozdev.org/) extension I can see what's going on.
1. There is no default time-to-live for images, such as "Cache-Control: max-age [seconds]" header. This would make browsers use cached image without even checking if updated version exists (for seconds secs) and I'm sure old forum did that. At least 86400 seconds (24 hours) would be good, perhaps 7 times more would be better (maybe not for avatars).
2. Server sends Last-Modified and E-Tag headers which are used to identify if image changed. Therefore, next time an image is loaded, browser sends If-Modified-Since and If-None-Match headers, and only expects to recieve an image (200 OK) if new version is available. Otherwise, it expects 304 Not Modified and can use the cached version.
Server's response is always 200 OK and then the image still has the same modification date and the same e-tag...
http://homepages.ihug.com.au/~syskin/http.png