caching - Nginx proxy_no_cache 和 proxy_cache_bypass

标签 caching nginx

这是文档:

proxy_cache_bypass
Defines conditions under which the response will not be taken from a cache. If at least one value of the string parameters is not empty and is not equal to “0” then the response will not be taken from the cache:
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
proxy_cache_bypass $http_pragma $http_authorization;
Can be used along with the proxy_no_cache directive.

proxy_no_cache
Defines conditions under which the response will not be saved to a cache. If at least one value of the string parameters is not empty and is not equal to “0” then the response will not be saved:
proxy_no_cache $cookie_nocache $arg_nocache$arg_comment;
proxy_no_cache $http_pragma $http_authorization;
Can be used along with the proxy_cache_bypass directive.


这是否意味着如果我想完全排除缓存中的某些内容,我应该同时设置 proxy_no_cacheproxy_cache_bypass ?如果我只设置proxy_cache_bypass可以吗? ?

最佳答案

是的。

如果您只有 proxy_cache_bypass 在您不希望缓存的页面(例如,登录用户)上设置为 true,那么它们仍将被保存到缓存中并提供给应该获取缓存页面的人(例如,非登录用户)。

但同时设置 proxy_cache_bypass proxy_no_cache 为 true 意味着这些用户既不接收也不贡献缓存。

关于caching - Nginx proxy_no_cache 和 proxy_cache_bypass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31694486/

相关文章:

Django QuerySets 和缓存

asp.net - ASP.NET 的缓存管理器

java - 如何防止多次同时加载非缓存值?

ssl - NGINX 将所有流量 www 和非 www http 重定向到 https ://example. com?

nginx - Kubernetes 部署上 ASP.NET Core 的粘性 session

caching - Varnish :具有多个 IP 的后端(或使用其他东西)

php - 拉维尔 5 : forget cache not working

nginx - 使用 nginx map 指令动态设置代理上游

php - nginx php-fpm 502 错误网关

Nginx 重写具有多个替换的查询参数