views:

50

answers:

2

Sorry if this question sounds a bit basic, I just want to be double sure.

I retrieve my images with a URL like so

image.jpg?m=54437

The end numbers allow me to cache control it. When the image changes, so do those numbers.

I am sending these headers with these images

HTTP/1.1 200 OK
Date: Thu, 01 Jul 2010 00:54:19 GMT
Server: Apache 
Last-Modified: Wed, 23 Jun 2010 01:06:58 GMT
Etag: "64b019c-49bb-489a8278e7080"
Accept-Ranges: bytes
Content-Length: 18875
Cache-Control: max-age=15552000
Expires: Tue, 28 Dec 2010 00:54:19 GMT
Content-Type: image/jpeg

So I thought with that expires header (currently adds 6 months from today) would mean the browser would not download it again until that time is up.

However, if that were the case, shouldn't the server return 304 not modified and not 200 OK?

Another strange this is when I view Firebug's net tab, those images do say 304 not modified.

Am I doing this correctly?

Thanks

Update

Here is a screenshot of Firebug

firebug.

If you visit here too, you can inspect the headers for yourself.

My .htaccess rules for the expiry looks like this

<IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/css "now plus 1 year"
        ExpiresByType text/javascript "now plus 1 year"
        ExpiresByType image/jpeg "now plus 6 months"
</IfModule>
+1  A: 

If it's truly cached by your browser, then you shouldn't be seeing returns of any kind on subsequent requests.

How are you setting the expires header? You should also look into removing the etag. Check YSlow for more details.

Jason McCreary
I used LiveHTTPHeaders to save the headers. I'll add a screenshot I think.
alex
Expires header is added with .htacess. I'll post it.
alex
Agreed with shadowhand, sometimes these tools can make be deceitful. I look at the statistics tab in the YSlow add-on for Firebug. Just a note, I would recommend adding your other image types: gif, png, etc.
Jason McCreary
+1 for taking the time to help.
alex
@Jason I haven't added the other images just yet because I don't have cache breakers automated for them, if I do need to update them. I'm hoping the defaults will suffice for now for them. I only wanted to cache control the JPEGs because they are large and for some parts will be displayed a lot.
alex
+2  A: 

First page load gives me a 200 status, second page load gives me a 304 status. Screenshot: http://cl.ly/1WBi Be careful when using header inspection tools, they usually bypass the browser cache entirely.

shadowhand
Thanks shadowhand, I didn't know the header inspection tool wouldn't return the right headers (I thought it would seeing as it is a plugin for Firefox).
alex

related questions