We have two Nginx servers with independent local caches for caching images. Periodically there is problem with unmanaged growth of cache's size. This size may be far larger than max_size
in nginx.conf
. As a result cache occupies all free disk space.
I want to understand what the reason of this issue might be.
Proxy cache config (nginx.conf
):
proxy_cache_path /opt2/nginx-cache-images1 max_size=150g levels=2:2 keys_zone=images1:1024m inactive=24h;
proxy_temp_path /opt2/proxy_temp 1 2;
Size of /opt2/nginx-cache-images1
is ~200GB.
Config of site location:
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Is-Referer-Search-Engine $is_referer_search_engine;
proxy_hide_header Set-Cookie;
proxy_hide_header Content-Disposition;
proxy_pass http://ua-image-proxy;
default_type image/jpeg;
proxy_cache images1;
proxy_cache_key ua$request_uri$is_referer_search_engine;
proxy_cache_valid 200 24h;
proxy_cache_valid 301 24h;
proxy_cache_valid 404 1h;
}
Nginx version: 1.7.7 and 1.7.9. It was compiled on Ubuntu 14.04.