For the last few weeks I've been trying to figure out how to properly configure caching for nginx sites and have had hit/miss (pun intended) results. The notes here are my attempt to keep up with what has worked so I can go from there.
Caching FastCGI content
From the FastCGI module wiki page:
The cache honors backend's Cache-Control, Expires, and etc. since version 0.7.48, Cache-Control: private and no-store only since 0.7.66, though. Vary handling is not implemented.
Parameters of caching can also be set directly in the response header. This has a higher precedence than setting of caching time using the directive. The
X-Accel-Expiresheader field sets caching time of a response in seconds. The value 0 disables the caching of a response. If a value starts with the prefix
@, it sets an absolute time in seconds since Epoch, up to which the response may be cached. If header does not include the
X-Accel-Expiresfield, parameters of caching may be set in the header fields
Cache-Control. If a header includes the
Set-Cookiefield, such a response will not be cached. Processing of one or more of these response header fields can be disabled using the