From e9e63a2625936b989144c3ff6379c945270fc239 Mon Sep 17 00:00:00 2001 From: Ivaylo Novakov Date: Mon, 14 Mar 2022 17:17:35 +0100 Subject: [PATCH] is it the proxy cache itself? --- docker/nginx/conf.d/include/location-skylink | 19 +------------------ .../conf.d/include/proxy-cache-downloads | 12 ++++++++---- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/docker/nginx/conf.d/include/location-skylink b/docker/nginx/conf.d/include/location-skylink index d9e54e2f..9b9e1b44 100644 --- a/docker/nginx/conf.d/include/location-skylink +++ b/docker/nginx/conf.d/include/location-skylink @@ -1,26 +1,9 @@ include /etc/nginx/conf.d/include/cors; +include /etc/nginx/conf.d/include/proxy-cache-downloads; -proxy_cache skynet; # cache name -proxy_cache_key $skylink$path$arg_format$arg_attachment$arg_start$arg_end$http_range; # unique cache key -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 - -# 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; - proxy_set_header User-Agent: Sia-Agent; proxy_pass http://sia:9980/skynet/skylink/$skylink$path$is_args$args; diff --git a/docker/nginx/conf.d/include/proxy-cache-downloads b/docker/nginx/conf.d/include/proxy-cache-downloads index 94a635e1..fffae384 100644 --- a/docker/nginx/conf.d/include/proxy-cache-downloads +++ b/docker/nginx/conf.d/include/proxy-cache-downloads @@ -1,7 +1,8 @@ -proxy_cache skynet; # cache name -proxy_cache_key $skylink$path$arg_format$arg_attachment$arg_start$arg_end$http_range; # unique cache key -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 +#proxy_cache skynet; # cache name +#proxy_cache_key $skylink_v1$path$arg_format$arg_attachment$arg_start$arg_end$http_range; # unique cache key +#proxy_cache_key $skylink$path$arg_format$arg_attachment$arg_start$arg_end$http_range; # unique cache key +#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 # map skyd env variable value to "1" for true and "0" for false (expected by proxy_no_cache) @@ -9,6 +10,9 @@ set_by_lua_block $skyd_disk_cache_enabled { return os.getenv("SKYD_DISK_CACHE_ENABLED") == "true" and "1" or "0" } +# I want to execute the above block but I also want to have it be a 1. # TODO: Remove this. +set $skyd_disk_cache_enabled "1"; + # 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;