I use nginx to proxy another nginx server, but this is somethine wrong about cache. The proxied server config file:
location ~* .*\.(gif|jpg|jpeg|bmp|png|ico|txt|pdf|doc|docx|xls|xlsx|ppt|pptx|vtt)$
{
include conf.d/open_file.conf;
include conf.d/static.conf;
expires 4d;
}
I set the pdf file expires after 4 days. But I use proxy_ignore_headers in proxy server:
location ^~ /pk/ {
proxy_pass http://pk_server/;
if ($request_method = 'OPTIONS' ) {
return 403;
}
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
proxy_set_header Remote_Addr $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
if ($http_x_forwarded_proto != '') {
set $final_scheme $http_x_forwarded_proto;
}
if ($http_x_forwarded_proto = '') {
set $final_scheme $scheme;
}
proxy_set_header X-Forwarded-Proto $final_scheme;
proxy_set_header Cookie $http_cookie;
proxy_set_header Cache-Control 'no-cache';
proxy_ignore_headers "Expires" "Cache-Control";
if ($args ~* nocache=) {
set $arg_nocache 1;
}
if ($request_uri ~* \.mp4$) {
set $arg_nocache 1;
}
proxy_cache ava_cache;
proxy_cache_valid 200 302 301 304 90s;
proxy_cache_key $host$uri$is_args$args;
add_header X-Cache $upstream_cache_status;
add_header X-Frame-Options SAMEORIGIN;
add_header Access-Control-Allow-Methods GET,POST,HEAD;
}
But my request respone with expires and the browser get pdf from disk cache after first request:
How could I do to let the browser to use If-Modified-Since to check if the file has been modified instead of read from disk cache