Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

When looking at the network waterfall in Firebug/Chrome/IE9, I keep seeing "200-OK" instead of "304-Not Modified" for many cache-able files (images, js, css) on this page, for example.

I believe it is because the browser is not sending a If-Modified-Since during the Request, right? Do I need to change something in the initial Response headers to make 304s happen?

FF13 screenshot

share|improve this question
    
Chrome screenshot –  utt73 Jun 12 '12 at 17:33
add comment

1 Answer

up vote 1 down vote accepted

I believe it is because the browser is not sending a If-Modified-Since during the Request, right?

Correct.

Do I need to change something in the initial Response headers to make 304s happen?

Yes. If you compare original response headers for those resources that have 304 response code on subsequent requests, you will notice:

  1. All of them located in /govtrip/site/grphx/ folder
  2. They have "Etag", "Expires" and "Last-Modified" headers

The first moment tells that most likely there is .htaccess file in that folder that sets those headers (or separate section elsewhere in config file for that folder).

If you look at request headers for those resources with 304 response code, you will see the presence of "If-Modified-Since" and "If-None-Match" headers. Based on those "If-*" headers Apache decides how to reply to the request. I'm sure -- now you can see a pattern here -- very easy to spot which values where used and where.

Resource: /govtrip/site/grphx/system_green.gif

Original response:

Etag: "AAAAS9z9eMo"
Expires: Thu, 14 Jun 2012 18:24:24 GMT
Last-Modified: Wed, 20 Apr 2011 17:29:45 GMT

Subsequent request:

If-Modified-Since: Wed, 20 Apr 2011 17:29:45 GMT
If-None-Match: "AAAAS9z9eMo"
share|improve this answer
    
That's what I was thinking also, but was not sure if sending Expires and Last-Modified was the only thing necessary. Does an Etag need to be sent, or will 304s happen without it? –  utt73 Jun 12 '12 at 20:14
    
Well .. general practice is to remove ETag to save a bit on bandwidth if other possible "If-*" header is present (which is the case in your example). 1) en.wikipedia.org/wiki/HTTP_ETag 2) webmasters.stackexchange.com/search?q=etag –  LazyOne Jun 12 '12 at 20:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.