proxy_cache_bypass and cache refresh

Grzegorz Kulewski gk at
Fri Oct 3 09:42:23 UTC 2014


Is it true that a GET request that satisfies proxy_cache_bypass (and generates BYPASS cache status in the access log) should also refresh proxy cache for that URL?

There are several tutorials on the Internet that advise that it works. Also it was working for us before but stopped - either after nginx upgrade or after some configuration change - not sure right now. We are currently running nginx 1.4.7.

Parts of configuration:

http {
proxy_cache_path /var/cache/www levels=1:2 keys_zone=foo-cache:256m max_size=4g inactive=1h;
proxy_cache_key "$host$request_uri";
proxy_cache_lock on;
proxy_cache_lock_timeout 120s;
proxy_no_cache $upstream_http_x_bar_dont_cache_me $cookie_x_no_cache;
proxy_cache_bypass $http_x_bar_cache_refresh $cookie_x_bar_no_cache;

location = / {
proxy_pass http://foo_old_www;
proxy_cache foo-cache;
proxy_cache_valid 200 1h;

Request to refresh cache (I double checked that it generates a GET request and a cache status BYPASS):

curl -H 'X-Bar-Cache-Refresh: true' -D - ''

Any idea why it doesn't work?

Grzegorz Kulewski

More information about the nginx mailing list