From 87e2a9e3bb0714b5f7cf84246511f4e2e3b3b28a Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 18 Feb 2022 13:06:48 +0100 Subject: [PATCH 1/2] add skynet-cache-ratio header to access log --- docker/nginx/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index f67438e5..64397630 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -50,7 +50,7 @@ http { '"$upstream_http_content_type" "$upstream_cache_status" ' '"$server_alias" "$sent_http_skynet_skylink" ' '$upstream_connect_time $upstream_header_time ' - '$request_time "$hns_domain" "$skylink"'; + '$request_time "$hns_domain" "$skylink" $upstream_http_skynet_cache_ratio'; access_log logs/access.log main; From 0bd5af87fc4366442077538fa607c37d6c22a1f0 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 18 Feb 2022 13:12:03 +0100 Subject: [PATCH 2/2] report bypass instead of miss when skyd cache is enabled --- .../nginx/conf.d/include/proxy-cache-downloads | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/nginx/conf.d/include/proxy-cache-downloads b/docker/nginx/conf.d/include/proxy-cache-downloads index c7405857..85aeeb9e 100644 --- a/docker/nginx/conf.d/include/proxy-cache-downloads +++ b/docker/nginx/conf.d/include/proxy-cache-downloads @@ -4,18 +4,18 @@ proxy_cache_min_uses 3; # cache after 3 uses proxy_cache_valid 200 206 307 308 48h; # keep 200, 206, 307 and 308 responses valid for up to 2 days add_header X-Proxy-Cache $upstream_cache_status; # add response header to indicate cache hits and misses -# bypass - this will bypass cache hit on request (status BYPASS) -# but still stores file in cache if cache conditions are met -proxy_cache_bypass $cookie_nocache $arg_nocache; - -# no cache - this will ignore cache on request (status MISS) -# and does not store file in cache under no condition -set_if_empty $nocache "0"; - # map skyd env variable value to "1" for true and "0" for false (expected by proxy_no_cache) set_by_lua_block $skyd_disk_cache_enabled { return os.getenv("SKYD_DISK_CACHE_ENABLED") == "true" and "1" or "0" } +# bypass - this will bypass cache hit on request (status BYPASS) +# but still stores file in cache if cache conditions are met +proxy_cache_bypass $cookie_nocache $arg_nocache $skyd_disk_cache_enabled; + +# no cache - this will ignore cache on request (status MISS) +# and does not store file in cache under no condition +set_if_empty $nocache "0"; + # disable cache when nocache is set or skyd cache is enabled proxy_no_cache $nocache $skyd_disk_cache_enabled;