0

I'm using Nginx and got a simple (maybe noobie) question about caching but I just want to be sure that I don't do anything bad :P

So I'm thinking about setting CSS, JS etc. files cache for one year and I also got this ETag + Last-Modified headers enabled.

Will the files update on client-side when I do any changes to them on the server (without changing filename)? Or am I missing something?

Thanks and sorry for a problem !

  • [This link](https://en.wikipedia.org/wiki/Web_cache#Cache_control) suggests not. – Richard Smith Jan 21 '18 at 14:59
  • To enable safe long-term caching, the URLs are usually 'versioned' - embedding a hash of the file contents - like app.6c74bd4ef32.js. The middle portion is part of an MD5 hash of the file itself. When the file changes, so will the hash – Alister Bulman Feb 27 '18 at 16:33

1 Answers1

0

After few tries and small research I've managed to achieve what I wanted.
add_header Cache-Control "no-cache"; expires 365d;
This will cache the files but also require them to revalidate each time.
Here you can find more details: https://stackoverflow.com/a/31130747/6188497