Nginx cache returns MISS after a few hours, can't be set up to cache "forever"

mig at mig at
Tue Nov 28 11:32:32 UTC 2017


I am trying to cache files "forever". Unfortunately in about 2-6 hours the cache starts to return MISS again. This is the setting:


proxy_cache_path /var/cache/nginx-cache  levels=1:2 keys_zone=mycache:10m max_size=20g inactive=10y;

proxy_cache_valid  10y;

"Expires" header returned by the upstream is set to the year 2027 and "Cache-Control" to max-age=315360000 (i.e. 10 years).


I suppose, if was the expiry time the reason, it would have return EXPIRED, but not MISS.

The cache fills up to ~5 GB (from allowed 20 GB), so the space should not be the problem.

I have tried to remove all cached files and restart nginx, but it did not help.

For testing I use plain curl GET requests (without ETag, Vary, etc. headers) - always the same.

Thank you for any hint,
Jan Molic

More information about the nginx mailing list