Nginx – Preventing 304 Not Modified Requests with nginx

nginx

I am running nginx, and have the following block for expiration:

expires 52w;

However when I use Google Chrome Developer Tools to observe network traffic, some of the assets are loaded from cache (200-from cache) while most of the assets are making a request to the server (304 Not Modified).

I want to load all assets from cache without communicating with the server if possible. (200-from cache)

What would be the required change in my nginx configuration?

Best Answer

What you're looking for is expires max; This sets a far-future header which most browsers will take to mean don't even bother asking if the resource was modified.

Remember, you can never control what requests any user agent will make you can only give it instructions and hope it listens. This is about the best you can do.