Google chrome is not updating the new css in website. It requires to clear cache everytime. My real concern is we cannot expect visitors to clear cache everytime while visiting the website. Can anyone suggest some solution that somehow chrome will load the updated file whenever a change is made file is uploaded.
Asked
Active
Viewed 3,133 times
0
-
Increase css version every time you make changes in css `styles.css?v2` – Abhishek Pandey Jun 21 '17 at 11:25
-
Do versioning whenever you change them. – Master.Deep Jun 21 '17 at 11:25
-
1Possible duplicate of [How to force browser to reload cached CSS/JS files?](https://stackoverflow.com/questions/118884/how-to-force-browser-to-reload-cached-css-js-files) – Rob Jun 21 '17 at 11:25
-
use gulp or webpack or similar tools to create version on every build , if problem is local on your system - use `ctrl+r` to refresh the page or use lite-server, browser-sync or similar – bhv Jun 21 '17 at 11:46
2 Answers
0
Assuming you have an external CSS file, use the following:
<link href="demo.css?v=1" rel="stylesheet" type="text/css">
Adding ?v=1 will make sure the file will be downloaded. When you have a new version of your CSS file, increase the number (v=2, v=3 and so on).

Gerard
- 15,418
- 5
- 30
- 52
-
It is a static website. versioning css with every change would require to change the version in all files. ( there are around 10-15 html files) . Any better solution? – Shruti Jun 21 '17 at 11:33
-
You can instruct the CSS to expire after a specific time using .htaccess. Alternatively, if you expect most visitors to access the site via the index page, using versioning only there may cover most of the cases. Both options are not 100% solutions. – Gerard Jun 21 '17 at 11:43