From a7cc85acd459c4f12d73cd55473b90a0f3a6aa7d Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 15 Jan 2021 16:11:06 +0100 Subject: [PATCH] improve nginx cache --- docker/nginx/conf.d/client.conf | 2 +- docker/nginx/conf.d/include/proxy-cache-downloads | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/nginx/conf.d/client.conf b/docker/nginx/conf.d/client.conf index 4d76586a..a10220a1 100644 --- a/docker/nginx/conf.d/client.conf +++ b/docker/nginx/conf.d/client.conf @@ -1,4 +1,4 @@ -proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=skynet:10m max_size=10g use_temp_path=off; +proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=skynet:10m max_size=10g inactive=24h use_temp_path=off; # ratelimit specified IPs geo $limit { diff --git a/docker/nginx/conf.d/include/proxy-cache-downloads b/docker/nginx/conf.d/include/proxy-cache-downloads index f3f82a5f..b1eb83f3 100644 --- a/docker/nginx/conf.d/include/proxy-cache-downloads +++ b/docker/nginx/conf.d/include/proxy-cache-downloads @@ -5,5 +5,6 @@ proxy_set_header Range $slice_range; # pass slice range to proxy proxy_cache_key $uri$arg_format$arg_attachment$slice_range; # use just the uri path, format and attachment args and slice range proxy_cache_min_uses 3; # cache responses after 3 requests of the same file proxy_cache_valid 200 206 24h; # cache 200 and 206 responses for 24 hours +proxy_cache_lock on; # queue cache requests for the same resource until it is fully cached proxy_cache_bypass $cookie_nocache $arg_nocache; # add cache bypass option add_header X-Proxy-Cache $upstream_cache_status; # add response header to indicate cache hits and misses