Log in

View Full Version : no time-to-live for forum images; server ignores browser's cache


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

Swede
10th December 2004, 13:45
That's very strange. This is what I get (manually telneting):

# telnet forum.doom9.org 80
Trying 194.242.112.78...
Connected to forum.doom9.org.
Escape character is '^]'.
GET /images/vb_bullet.gif HTTP/1.1
Host: forum.doom9.org
Connection: keep-alive
If-modified-since: Fri, 26 Nov 2004 13:47:55 GMT
In-none-match: "2803a-18c-90e8b4c0"

HTTP/1.1 304 Not Modified
Date: Fri, 10 Dec 2004 12:43:05 GMT
Server: Apache/2.0.52 (Debian GNU/Linux) PHP/4.3.9-1
Connection: Keep-Alive
Keep-Alive: timeout=15, max=100
ETag: "28067-25c-91dcd8c0"

sysKin
10th December 2004, 15:40
Oh... damn, you ARE right of course.
It was my firewall. Well, it still is my firewall, I'll be poking at it until it stops. I wonder what happened, I still get 304s for other websites even with firewall active. Oh well.

Apologies for false alarm.
Radek