Search code examples
nginxbrowser-cachemultiple-browsers

Caching static resources on nginx and browser behaviour


I wanted to cache static resources so I set an expires header for static resources.

After setting the expires header, what I notice is:

  1. Firefox and IE do not send requests to nginx for static resources
  2. But all other browsers(Chrome, Safari, Opera) send a request to my nginx and nginx responds with 304 Not Modified

Are chrome, safari, opera caching my static resources? Is this normal behaviour? If not what should I do in addition so that static resources are cached by the other browsers?


Solution

  • Take a careful look at the subsequent HTTP requests from chrome/safari/opera:

    It's most likely a conditional GET. Also, the 304 Not Modified does not have a body.

    So these browser cache too, just don't trust the content to stay the same before the expiration date.

    They are just sniffing the milk in the fridge more often :-)