I am doing the following
$ curl -X GET -I -H "Cache-Control: no-cache" https:/myserver/myimage.jpg
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Wed, 24 Jun 2015 22:55:31 GMT
Content-Type: image/jpeg
Content-Length: 37502
Connection: keep-alive
Etag: "wzsdm-1434973626-37502-1204291434"
Cache-Control: max-age=604800, public
Expires: Wed, 01 Jul 2015 22:43:01 GMT
X-Proxy-Cache: HIT
Where I expect to get the following instead
X-Proxy-Cache: BYPASS
My configuration on Nginx is as follow:
location ~* \.(?:jpg|jpeg|gif|png|pdf|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
proxy_cache my_zone;
add_header X-Proxy-Cache $upstream_cache_status;
include proxy_params;
proxy_pass http://my-backend;
}
Is there any configuration I could have missed out?
By default, Nginx's cache does not honour the
Cache-Control:no-cache
request header, nor thePragma:no-cache
request header. You must explicitly configure Nginx to bypass the cache and pass the request onto the origin server when the user agent sends these request headers.Add the following lines to your configuration file:
From Nginx's caching guide: