Wed 06 Jan 2016 — Wed 06 Mar 2019
Nginx can cache static files it serves using
expires 1h; inside a location block.
It can also cache proxied requests using
proxy_cache. This is a slightly complicated thing which involves setting up a zone and a key.
- Cache-Control header:
- can anywhere (e.g. CDN or ISP) vs only cache in the browser.
- never use the cache.
- always ask the server for the etag. If it matches, use the cache.
- we can use the cached resource for this long. Afterwards, we need to check the etag to renew the cache.
- an override for CDNs.
- don't use this. Cache-Control takes precedence. However, in Nginx you configure the Cache-Control header using the
- a hash identifying a resource. This will be checked against the server's etag when a cached file hits its expiry time.
- specify headers which the cache will vary over.
- ignore this. Olden days.