Triggering proxy_cache_bypass on a request that was previously cached, will serve a fresh response from upstream. But if that response now returns a Cache-Control: no-cache header, the old cached response is not replaced nor cleared. Which means that subsequent requests that do not trigger proxy_cache_bypass will keep serving an old response.

I guess this is an intended behavior, because proxy_cache_bypass only *replaces* cached responses by storing a fresh one, and a no-cache response means there is nothing to store? Is this what's happening?

Is there a way to work around this?

I'm running nginx/1.14.2 . Relevant settings:


proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my-cache:70m max_size=28g inactive=1d;
proxy_temp_path /var/cache/nginx/tmp;
proxy_cache my-cache;
proxy_cache_key $remote_user$scheme$host$request_uri;

proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504 http_429;

proxy_cache_bypass $http_cache_control;

proxy_read_timeout 90;
add_header X-Cache-Status $upstream_cache_status;

etag off;


Thanks

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to