website files saved in browse's cache prevent changes from being displayed

126 Views Asked by At

This is probably a dumb question, but I'm worried :

  • I have published a website on a server, then made some changes to a css file.
  • As the css file was already cached by my browser, it didn't display the changes.
  • deleting the cash allowed to display the changes.

Now my worry is that if some users have previously been to the website, and it is cached by their browser, if I make a change they wouldn't be able to see it.

How do you guys prevent this ? Do you just change the file names ?

Sorry for my noobness, Thanks.

1

There are 1 best solutions below

0
On

There are a number of solutions floating around the web, but as far as I can tell they all boil down to changing the CSS filenames whenever their content changes. That way you steer clear of user caches and server caches serving old content.

Variants:

  • Instead of changing the name of the file itself, create a symbolic link with a new name to the old file whenever content changes.

  • Instead of changing the name of the file, change the way it is referenced by the page. Replacing myfile.css?v=1 by myfile.css?v=2 circumvents people's caches.

  • Write code that automatically changes the name or the link name or the way the file is referenced

  • Use a framework that does one of the above.

And: remember that the same problem applies to any content that might be cached, like JS files.