nginx 使用过时的缓存不工作
nginx use stale cache not working
我正在尝试使用proxy_cache_use_stale错误;让 nginx 在目标 returns http 状态 500 内部错误时提供缓存页面。
我有以下设置:
location /test {
proxy_cache maincache;
proxy_cache_valid 200 10s;
proxy_cache_use_stale error;
proxy_pass http://127.0.0.1:3000/test;
}
location /toggle {
proxy_pass http://127.0.0.1:3000/toggle;
}
测试将 return 当前时间和 Http 状态 200 或当前时间和 http 状态 500。如果我调用 /toggle 从 /test 编辑的值 return 将从 200 切换到500.
我的期望是我应该能够向 /test 发送调用并获取当前时间。然后,我应该能够向 /toggle 发送调用,而对 /test 的调用将 return 首次调用该函数的时间。发生的事情是它将其最后一个缓存保留 10 秒,然后发回当前时间并且根本不使用缓存。
我理解设置 proxy_cache_valid 200 10s;当 returned 不是 500 时将阻止它刷新缓存,并在 10 秒过去后将新内容存储在缓存中并且出现 none 错误消息
return编辑。
我在阅读文档后假设,旧缓存不会自动清除,直到时间过去等于为缓存设置的非活动标志。我没有为缓存设置非活动标志,所以我希望 "proxy_cache_use_stale error" 会阻止缓存刷新,直到 10 分钟过去(未定义非活动时的默认值),或者错误不再 returned .我误解了文档的哪一部分?这应该如何正确完成?
我所指的 Nginx 文档是在这里找到的。
http://nginx.org/en/docs/http/ngx_http_proxy_module.html?&_ga=1.112574977.446076600.1424025436#proxy_cache
您应该使用 "http_500" 而不是 "error",请参阅 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream(proxy_cache_use_stale 使用与 proxy_next_upstream 相同的参数)
我正在尝试使用proxy_cache_use_stale错误;让 nginx 在目标 returns http 状态 500 内部错误时提供缓存页面。 我有以下设置:
location /test {
proxy_cache maincache;
proxy_cache_valid 200 10s;
proxy_cache_use_stale error;
proxy_pass http://127.0.0.1:3000/test;
}
location /toggle {
proxy_pass http://127.0.0.1:3000/toggle;
}
测试将 return 当前时间和 Http 状态 200 或当前时间和 http 状态 500。如果我调用 /toggle 从 /test 编辑的值 return 将从 200 切换到500.
我的期望是我应该能够向 /test 发送调用并获取当前时间。然后,我应该能够向 /toggle 发送调用,而对 /test 的调用将 return 首次调用该函数的时间。发生的事情是它将其最后一个缓存保留 10 秒,然后发回当前时间并且根本不使用缓存。
我理解设置 proxy_cache_valid 200 10s;当 returned 不是 500 时将阻止它刷新缓存,并在 10 秒过去后将新内容存储在缓存中并且出现 none 错误消息 return编辑。
我在阅读文档后假设,旧缓存不会自动清除,直到时间过去等于为缓存设置的非活动标志。我没有为缓存设置非活动标志,所以我希望 "proxy_cache_use_stale error" 会阻止缓存刷新,直到 10 分钟过去(未定义非活动时的默认值),或者错误不再 returned .我误解了文档的哪一部分?这应该如何正确完成?
我所指的 Nginx 文档是在这里找到的。 http://nginx.org/en/docs/http/ngx_http_proxy_module.html?&_ga=1.112574977.446076600.1424025436#proxy_cache
您应该使用 "http_500" 而不是 "error",请参阅 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream(proxy_cache_use_stale 使用与 proxy_next_upstream 相同的参数)