2

While working on some optimizations for my site, I noticed some things in Networking Timings for Chrome Developer Tools differ from those in Firefox Developer Tools.

Very consistently Chrome loads a number of items on the page giving a "200 (from cache)" response. Those same items on Firefox just show as 304 response items.

I am wondering if anyone can explain this. Below are two screen shots for the same resource. First one from Chrome, the second from Firefox.

Example from Chrome

example from Firefox

3
  • I am just assuming here... the 304 is a "not modified" as a result of a HEAD request of the file and the 200 from cache is just Chromes way of saying the same thing- but different. The 304 is likely more technically correct.
    – closetnoc
    Jun 1, 2015 at 4:20
  • 1
    As I understand it, "from cache" means no request to the server at all, but 304 means that a round trip was made to the server, and the "not changed" header was returned. So these are definitely two different things, and "should not" be simply saying the same thing, although it is a small difference. Jun 2, 2015 at 16:21
  • I understand. That was my assumption. The 202 I interpreted as not making a HEAD request at all but going right to cache. For all practical purposes, while there is a difference, the result would be that the resource was served from cache and therefore similar in that respect but not exactly identical in actual process.
    – closetnoc
    Jun 2, 2015 at 16:25

1 Answer 1

1

This is how an asset (such as an image) is delivered from the server at excellent speed.

  1. When a new connection is made, the server returns the image with status code 200 (OK). It also returns either a cache-control header with a reasonable max-age value of a number in seconds equal to at least 6 months or an expires header with a date at least 6 months in the future or both. Also, a last-modified or e-tag header is returned.

  2. When requesting the resource again without any manual refresh, the asset loads super quick as the cache hasn't expired.

  3. About 6 months later (after cache expired), a request is made to the server for the image along with an if-modified-since or if-none-match header (depending on if last-modified or e-tag was sent to the browser after the first request), and the server compares the data in the headers to see if they match up and if they do, then the server returns a 304 status code with no content, indicating to the browser that it can continue to load its cached content as if its the valid and most updated asset.

I think with google chrome, they like to declare cached responses as 304 status codes. I also read somewhere online that chrome disrespects the cache-control max-age setting in some cases.

See: https://superuser.com/questions/313131/how-do-i-stop-chrome-sending-cache-control-max-age-0-when-i-hit-enter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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