I have made a web-page where I omit the file extension when I link to an image ( <img src="pic" /> instead of <img src="pic.png" /> for example).
This still causes my webserver to return the correct image since I have the 'MultiViews' option enabled, so the server looks for pic.* and chooses the most appropriate one to send back to the client - but in my case there is only ever one image so clients always get the same file no matter what.
I am doing this
a) to simplify maintenance - if I want to switch a GIF to a PNG or something like that I don't need to update all my pages and...
b) because using a little CGI I want to make the site themable. All the images' names have a common prefix, so to change a theme I just change the prefix and it refers to totally seperate bunch on images. However, equivaltent images in different themes may use different file formats which is why I'm avoiding the extensions
Ok, on to my problem. I set all of this up and it worked beautifully in Mozilla, Safari, Opera, IE (Mac version) and even iCab. Internet Explorer (windows version), however, reloads all of the images from the server on every page, every time. I use JavaScript rollover images on the page and even those reload every time you run the mouse over them. It appears to refuse to cache any of the images (whereas all the other browsers *do* cache them as usual). This obviously slows page loading for visitors and wastes my server's bandwidth.
I looked at my servers HTTP response headers (using wget) for the content-negotiated image files and they do have a few extra lines so I suspect that's what's causing it.
The old style response (when I request the file with the extension) is as follows (for
http://yvette.twiddles.com/style/rose_home.png ):
1 HTTP/1.1 200 OK
2 Date: Sun, 11 Apr 2004 11:57:24 GMT
3 Server: Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2
4 Last-Modified: Thu, 08 Apr 2004 18:12:27 GMT
5 ETag: "6f1a-b89-4075960b"
6 Accept-Ranges: bytes
7 Content-Length: 2953
8 Keep-Alive: timeout=15, max=50000
9 Connection: Keep-Alive
10 Content-Type: image/png
Without the extension (
http://yvette.twiddles.com/style/rose_home ) I get:
1 HTTP/1.1 200 OK
2 Date: Sun, 11 Apr 2004 11:58:47 GMT
3 Server: Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2
4 Content-Location: rose_home.png
5 Vary: negotiate
6 TCN: choice
7 Last-Modified: Thu, 08 Apr 2004 18:12:27 GMT
8 ETag: "6f1a-b89-4075960b;407845ce"
9 Accept-Ranges: bytes
10 Content-Length: 2953
11 Keep-Alive: timeout=15, max=50000
12 Connection: Keep-Alive
13 Content-Type: image/png
Lines 4,5 & 6 are new and the ETag is slightly different. This must be what makes IE not cache the file.... but why???
I tried adding an 'Expires' date to the header but it made no difference.
Presumably this would affect any transparently content-negotiated content so I assumed others would have had the same problem but I could not find any mention of it on google, msdn or within apache's documentation.
Does anyone have an idea how I can fix this?
The site I'm working on is
http://yvette.twiddles.com/ (it's for my girlfriend so excuse the cheesyness :P) Currently most pages still refer to images by their full names and hence behave well in IE - the only page I changed so far is the links page
http://yvette.twiddles.com/links/ - visually it should have the same style as the rest but the images will always reload in IE.
Any help would be much appreciated!
Cheers!
-James