Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a browser to clear the cache on my website .html files

I've recently made changes to a clients website but the browser is showing a cached version. It's a static website with .html files. If I delete the cache on my browser it works but what i really want is to force every visitors browser to show the latest version without them having to manually delete their cache.

I understand that you can set a version on .css & .js file to show the latest version but how do you do this with static .html files?

like image 408
Shaun Avatar asked Nov 26 '25 08:11

Shaun


1 Answers

If this is about .css and .js changes, one way is to to "cache busting" is by appending something like "_versionNo" to the file name for each release. For example:

script_1.0.css // This is the URL for release 1.0
script_1.1.css // This is the URL for release 1.1
script_1.2.css // etc.

Or alternatively do it after the file name:

script.css?v=1.0 // This is the URL for release 1.0
script.css?v=1.1 // This is the URL for release 1.1
script.css?v=1.2 // etc.

And you can have a look at here too META TAGS

like image 149
Baransel A. Avatar answered Nov 28 '25 02:11

Baransel A.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!