【问题标题】:Nginx and disappearing cacheNginx 和消失的缓存
【发布时间】:2022-08-23 03:20:53
【问题描述】:

我的流媒体服务器前面需要某种屏蔽服务器。我有非常基本的 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 分钟内为空,但我看不出有什么原因。请帮助修复它。

    标签: nginx caching


    【解决方案1】:

    问题出在不活跃参数proxy_cache_path指令 - 默认为 10 分钟。

    【讨论】:

      猜你喜欢
      • 2012-08-20
      • 2017-09-08
      • 1970-01-01
      • 2015-09-17
      • 2016-09-16
      • 2013-09-30
      • 1970-01-01
      • 2012-12-03
      • 1970-01-01
      相关资源
      最近更新 更多