
If so, perhaps you just have not reloaded nginx after the change sudo nginx -s reload. So it looks like one should only use cache-control: public when they explicitly want to override these rules for cacheability, which in general is probably not a good idea. Is your origin sending back a Cache-Control header Or is this one of the files that would be served directly from file system.
#ADDING PUBLIC PRIVATE CACHE HEADER CODE#
The status code of the response is known by the application caching, and it is considered cacheable.) Other methods, like PUT or DELETE are not cacheable and their result cannot be cached. (For example, Firefox does not support it per.
#ADDING PUBLIC PRIVATE CACHE HEADER PATCH#
A response to a POST or PATCH request can also be cached if freshness is indicated and the Content-Location header is set, but this is rarely implemented.

Not all HTTP responses can be cached, these are the following constraints for an HTTP response to be cached: After 5 minutes has expired, the file will have to be retrieved again from the server.

For example, if the Cache-Control header is set to 5 minutes, a browser will download the file and cache it for five minutes. Over 200k developers use LogRocket to create better digital experiences Learn more The local cache (e.g., browser) can still cache private responses. This defines the amount of time a file should be cached. The difference between public and private is that a shared cache (e.g., CDN) can cache public responses but not private responses. So what does "cacheable" mean? From the "cacheable" page on the MDN glossary:Ī cacheable response is an HTTP response that can be cached, that is stored to be retrieved and used later, saving a new request to the server. One of the most common headers to add to a page is Cache-Control. The response may be stored by any cache, even if the response is normally non-cacheable (emphasis mine).

Many responses normally shouldn't be cached - e.g. (Section 5.2) The public and private cache directives were clarified, so. TL DR: cache-control: public will explicitly override the default rules for which sort of responses are considered cacheable, so shouldn't be used lightly. When doing so, the cache MUST add each header field in the provided response to. On more careful reading of MDN, I think I've found the answer to my own question.
