Nginx proxy_no_cache和proxy_cache_bypass

lai*_*e9m 8 caching nginx

这是文档:

proxy_cache_bypass
定义不从缓存中获取响应的条件.如果字符串参数的至少一个值不为空且不等于"0",则不会从缓存中获取响应:
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
proxy_cache_bypass $http_pragma $http_authorization;
可以与proxy_no_cache指令一起使用.

proxy_no_cache
定义不将响应保存到缓存的条件.如果字符串参数的至少一个值不为空且不等于"0",则不会保存响应:
proxy_no_cache $cookie_nocache $arg_nocache$arg_comment;
proxy_no_cache $http_pragma $http_authorization;
可以与proxy_cache_bypass指令一起使用.

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

Mar*_*ker 16

是.

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

但是将proxy_cache_bypassproxy_no_cache都设置为true意味着这些用户既不接收也不参与缓存.

  • 被这个抓住了 很多教程/示例只提到了 proxy_cache_bypass 而不是 proxy_no_cache。想知道为什么该网站的访问者看到它就像他们已经登录一样。 (2认同)