0

I'm trying to set up caching in nginx so that images will not need to be fetched repeatedly. It seems to be working except that the browser is still making a request for each file with an If-Modified-Since header. The server then responds with 304 Not Modified and the actual file isn't transferred again. I can see how this is desired behavior in a lot of cases but in my particular situation it's fine for the files to be up to a week out of date and I would prefer to skip the delay introduced by the extra requests.

Is it possible to add cache headers that tell the browser to always automatically use the cached version until the expiration is reached? My current nginx config is

expires 7d;
add_header Pragma public;
add_header Cache-Control "public";
Ivanna
  • 1,197
  • 1
  • 12
  • 22

1 Answers1

0

From researching this more it appears that these requests at the browsers discretion and it doesn't have anything to do with the nginx configuration. If you do a ctrl-f5 refresh in Chrome then it will re-request all files, regardless of whether or not they're cached. If you do just f5 then it will send the requests with the 'If-Modified-Since' header and then only update the files if they've been changed (this is what I was doing). When you simply click a link to a page then the cached files aren't requested.

Ivanna
  • 1,197
  • 1
  • 12
  • 22