Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx proxy_no_cache and proxy_cache_bypass

Tags:

caching

nginx

Here's the documentation:

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.

Does that mean if I want to totally exclude something in cache, I should set both proxy_no_cache and proxy_cache_bypass? Is it OK if I only set proxy_cache_bypass?

like image 708
laike9m Avatar asked Jul 29 '15 07:07

laike9m


People also ask

What is Proxy_cache_bypass?

Defines conditions under which the response will not be taken from a cache.

Can NGINX cache dynamic content?

Cache both static and dynamic content from your proxied web and application servers, to speed delivery to clients and reduce the load on the servers.

Does NGINX have cache?

By default, NGINX Plus and NGINX serve cached content for as long as it is valid. Validity is configurable or can be controlled by the Cache-Control header set by the origin server.

How do I enable caching in NGINX?

Go to the “Web Server” tab. In the “nginx settings” section, select the “Enable nginx caching” checkbox. (Optional) You can customize nginx caching settings. If you are not familiar with nginx caching, we recommend that you keep the default settings.


1 Answers

Yes.

If you just have proxy_cache_bypass set true on pages you don't want cached (eg. logged in users) then they will still be saved into the cache and served to people who should get cached pages (eg. non logged in users).

But setting both proxy_cache_bypass and proxy_no_cache to true means that those users neither receive nor contribute to the cache.

like image 195
Mark Walker Avatar answered Sep 22 '22 04:09

Mark Walker