2021-05-31 18:27:56 +00:00
|
|
|
proxy_cache skynet; # cache name
|
2022-03-11 08:10:12 +00:00
|
|
|
proxy_cache_key $skylink$path$arg_format$arg_attachment$arg_start$arg_end$http_range; # unique cache key
|
2021-08-11 09:48:15 +00:00
|
|
|
proxy_cache_min_uses 3; # cache after 3 uses
|
2021-09-07 10:56:25 +00:00
|
|
|
proxy_cache_valid 200 206 307 308 48h; # keep 200, 206, 307 and 308 responses valid for up to 2 days
|
2020-09-01 13:26:48 +00:00
|
|
|
add_header X-Proxy-Cache $upstream_cache_status; # add response header to indicate cache hits and misses
|
2022-01-03 15:38:51 +00:00
|
|
|
|
2022-02-18 12:12:03 +00:00
|
|
|
# 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"
|
|
|
|
}
|
|
|
|
|
2022-01-03 15:38:51 +00:00
|
|
|
# bypass - this will bypass cache hit on request (status BYPASS)
|
|
|
|
# but still stores file in cache if cache conditions are met
|
2022-02-18 12:12:03 +00:00
|
|
|
proxy_cache_bypass $cookie_nocache $arg_nocache $skyd_disk_cache_enabled;
|
2022-01-03 15:38:51 +00:00
|
|
|
|
|
|
|
# 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";
|
2022-02-10 13:50:36 +00:00
|
|
|
|
|
|
|
# disable cache when nocache is set or skyd cache is enabled
|
|
|
|
proxy_no_cache $nocache $skyd_disk_cache_enabled;
|