【问题标题】:Nginx proxy_no_cache and proxy_cache_bypassNginx proxy_no_cache 和 proxy_cache_bypass
【发布时间】:2015-10-20 01:58:06
【问题描述】:

这是文档:

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可以吗?

【问题讨论】:

    标签: caching nginx


    【解决方案1】:

    是的。

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

    但是将 proxy_cache_bypassproxy_no_cache 都设置为 true 意味着这些用户既不会接收缓存,也不会贡献缓存。

    【讨论】:

    • 被这个抓住了。很多教程/示例只提到 proxy_cache_bypass 而不是 proxy_no_cache。想知道为什么该网站的访问者看到它就像他们已经登录一样。
    猜你喜欢
    • 2020-09-17
    • 2014-10-22
    • 2011-01-01
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多