Nginx和消失的缓存



我需要一些屏蔽服务器在我的流媒体服务器前面。我有非常基本的nginx配置:

proxy_cache_path /localcache/nginx levels=2:2:2 keys_zone=cache:128m;
server {
listen *:80;
server_name _;
proxy_cache cache;
proxy_cache_lock on;
# Immediately forward requests to the origin if we are filling the cache
proxy_cache_lock_timeout 0s;
# Set the 'age' to a value larger than the expected fill time
proxy_cache_lock_age 5s;
proxy_cache_valid 200 36500d;
proxy_cache_use_stale updating;
proxy_cache_methods GET;
location /streamer/ {
proxy_set_header Host streamser.server.exapmle;
proxy_pass_request_headers off;
proxy_hide_header Cache-Control;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers x-accel-expires;
proxy_ignore_headers expires;
proxy_hide_header etag;
proxy_http_version 1.1;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Connection "";
proxy_pass https://111.222.333.444;
add_header Set-Cookie chost=$Host;
add_header XX-Cache-Status $upstream_cache_status;
}
}

我想永远缓存-直到我手动清除特定的文件。当我第一次观看视频时,我可以看到标题XX-Cache-Status如预期的那样显示MISS,我看到缓存文件夹在增长

sudo du -hs vol/localcache/nginx/
62M     vol/localcache/nginx/

当我倒带视频时,我看到XX-Cache-Status变为HIT -看起来不错。但是!一段时间后,我发现缓存文件夹越来越小:

sudo du -hs vol/localcache/nginx/
42M     vol/localcache/nginx/

看起来缓存正在清理,但我不明白为什么。这发生在视频播放时。当我停止游戏时,我发现缓存文件夹在10-15分钟内是空的,但我不知道为什么。请帮忙修复。

问题出现在proxy_cache_path指令的inactive参数中-默认为10分钟。

最新更新