Nginx cache 1 KEY into multiple cache files (cache not running)

Maxim Dounin mdounin at mdounin.ru
Thu Nov 19 13:26:02 UTC 2015


Hello!

On Wed, Nov 18, 2015 at 09:40:45PM -0500, semseoymas wrote:

> First, the specs:
> nginx version: nginx/1.8.0

[...]

> The problem here: if people asks nginx for the same request_uri, it will
> create multiple files!! this way, the cache is not running ok... 

Multiple cache files for the same key can be created if a backend 
response uses the Vary mechanism to allow multiple resource 
variants.  It is supported and taken into account when caching 
since nginx 1.7.7, http://nginx.org/en/CHANGES:

    *) Change: now nginx takes into account the "Vary" header line in a
       backend response while caching.

If responses are really the same, consider removing Vary from 
backend responses.  If it not possible for some reason, you can 
use proxy_ignore_headers to stop nginx from handling Vary in 
responses, e.g.:

    proxy_ignore_headers Vary;

Some additional details can be found in the documentation here:

http://nginx.org/r/proxy_ignore_headers

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list