views:

2199

answers:

5

I'm using the Google "Page Speed" plug-in for Firefox to access my web site.

Some of the components on my page is indicated as HTTP status:

200 200 (cache) 304

By Google's "Page Speed".

What I'm confused about is the difference between 200 (cache) and 304.

I've refreshed the page multiple times (but have not cleared my cache) and it always seems that my favicon.ico and a few images are status=200 (cache) while some other images are http status 304.

I don't understand why the difference.

UPDATE:

Using Google "Page Speed", I receive a "200 (cache)" for http://example.com/favicon.ico as well as http://cdn.example.com/js/ga.js

But, I receive a http status "304" for http://cdn.example.com/js/combined.min.js

I don't understand why I have two JavaScript files located in the same directory /js/, one returning a http status 304 and the other returning a 200 (cache) status code.

A: 

304 is unmodified. i get this code a lot in my media files like css and js.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5

Brandon H
So does a "200 (cache)" mean that my browser had to re-download the entire content again to then determine it hadn't changed from what was in cache? Ideally, it seems like I would want 304 status messages and not "200 (cache)"
Hank
Yeah, but favicon is a file too, it's not a server script or something.
x2
I've updated my original post to show my live site and the JavaScript in question. Please see my updated original post.
Hank
+3  A: 

The items likely have long-lasting Expires: or similar headers that denote that they will be valid for awhile without refresh, or are a special case like favicons (most browsers cache them awhile without checking for changes unless you force-refresh or clear cache), So the browser is not even checking whether these items were modified, just pulling them straight from cache.

304s, on the other hand, are the response of the server after the browser has checked if the file was modified since the last version it had cached (the answer being "no").

When Firebug shows the 200 responses, there was not in fact a 200 response from the server (there wasn't even a request sent to the server), that's just the status code used to indicate that there was a successful retrieval from local cache of the item.

Ben
So what's better to have from a speed perspective ... "200 (cache)" or "304" http status messages?
Hank
200 cache. Some good notes about this here: http://developer.yahoo.com/performance/rules.html#expires . You want as long an expiration time as possible on your assets, but have to balance this with the fact that you lose a certain amount of control this way.One thing you can do is set long-lasting expirations on files, and then when needed increment an asset version number for those files. For example you can include style.css?v1 and increment in the <link> element to style.css?v2 when there are changes.
Ben
I've updated my original post to show my live site and the JavaScript in question. Please see my updated original post.
Hank
Exactly. Firebug is reporting that *it pulled a `200 OK` response from the local cache*. In other words, Firebug actually did a request/response cycle half an hour ago, and has cached the result: the result was a `200 OK`, and the result still is a `200 OK`, only now the result is coming from the cache rather than from the server.
Justice
Justice, so why is Firebug report that for the ga.js is pulled from the local cache (status = 200 cache) while the combined.min.js is reporting a 304 http status. What's strange is that both files are of the same file type (JavaScript) and reside in the same server directory. You would think both would be either 200 or 304, and not different
Hank
here are the different firefox refresh methods http://www-jo.se/f.pfleger/firefox-reload
Josef
+1  A: 

HTTP 304 is "not modified". Your web server is basically telling the browser "this file hasn't changed since the last time you requested it." Whereas an HTTP 200 is telling the browser "here is a successful response" - which should be returned when it's either the first time your browser is accessing the file or the first time a modified copy is being accessed.

For more info on status codes check out http://en.wikipedia.org/wiki/List%5Fof%5FHTTP%5Fstatus%5Fcodes.

richleland
That's my understanding as well ... which is why I stated in my original post that I've refreshed my page multiple times and am still getting the "200 (cache)" for the same favicon.ico and particular JavaScript includes I have. Very strange
Hank
200 actually doesn't mean cached, it just means OK. Chances are that your server configuration doesn't explicitly tell the browser to cache your ico and js files, which would make it return a status code of 200.
richleland
That's not the case b/c on some of my JavaScript, I receive a 304 and other JavaScript I get a "200 (cache)". All JavaScript resides within the same web server directory example.com/js/
Hank
I should add that 200 (cache) just means it's locally cached and not actually making a request to the server, which is going to be faster than going to the server and getting a 304 response.
richleland
I've updated my original post to show my live site and the JavaScript in question. Please see my updated original post.
Hank
A: 

This new pagespeed craze is driving me nuts! There is 0 documentation on some of the data outputted, including this "200(cache)" issue... Almost more frustrating though are the explanations that are given. As a 'noob' to this caching thing, another thing that bothered me is lack of real guidance after advice. The page does a good job of explaining what things like 'serving static content from a cookieless domain' and/or 'Parallelize downloads across hostnames' are, but do not do a good job of explaining exactly how to go about doing these things...

That's my rant and now I also have a question... i am frequently calling different 'static' elements (ie: header.php, sidebar.php, porn-widget.php, etc) throughout my site with statements. For page load times should these elements use require_once as they are not doing anything dynamic?

Thanks and you are a hero if you read all this.

Start a separate question for your question, and in the future, move rants to the comments section.
mattbasta
A: 

200 (cache) means Firefox is simply using the locally cached version. This is the fastest because no request to the Web server is made.

304 means Firefox is sending a "If-Modified-Since" conditional request to the Web server. If the file has not been updated since the date sent by the browser, the Web server returns a 304 response which essentially tells Firefox to use its cached version. It is not as fast as 200 (cache) because the request is still sent to the Web server, but the server doesn't have to send the contents of the file.

To your last question, I don't know why the two JavaScript files in the same directory are returning different results.

James Lawruk