Nginx的proxy_no_cache和proxy_cache_bypass

这里是文档:

proxy_cache_bypass
定义不会从caching中获取响应的条件。 如果string参数中至less有一个值不为空且不等于“0”,则不会从caching中获取响应:
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
proxy_cache_bypass $http_pragma $http_authorization;
可以和proxy_no_cache指令一起使用。

proxy_no_cache
定义响应不会保存到caching的条件。 如果string参数中至less有一个值不为空且不等于“0”,则不会保存响应:
proxy_no_cache $cookie_nocache $arg_nocache$arg_comment;
proxy_no_cache $http_pragma $http_authorization;
可以和proxy_cache_bypass指令一起使用。

这是否意味着如果我想完全排除caching中的东西,我应该设置proxy_no_cacheproxy_cache_bypass ? 如果我只设置proxy_cache_bypass吗?

是。

如果你只是在不想被缓存的页面上设置了proxy_cache_bypass (例如,登录用户),那么它们仍然会被保存到缓存中,并提供给那些应该获得缓存页面的用户(例如非登录用户)。

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