A forced way to clear browser cache
P粉727531237
P粉727531237 2023-08-13 15:04:36
0
2
536
<p>Is there a way I can put some code on my page so that when someone visits the site, it clears the browser cache so they can see the changes? </p> <p>Languages ​​used: ASP.NET, VB.NET, and of course HTML, CSS and jQuery. </p>
P粉727531237
P粉727531237

reply all(2)
P粉253518620

See the cache-control and expires META tags.

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="Mon , 22 Jul 2002 11:12:01 GMT">

Another common practice is to append a changing string to the end of the requested file. For example:

<script type="text/javascript" src="main.js?v=12392823"></script>

P粉587970021

If this is a change regarding .css and .js, one way to do this is by appending something like "_versionNo# to the end of each published filename ##" content to perform "cache destruction". For example:

script_1.0.css // 这是发布 1.0 的 URL
script_1.1.css // 这是发布 1.1 的 URL
script_1.2.css // 等等
or after the file name:

script.css?v=1.0 // 这是发布 1.0 的 URL
script.css?v=1.1 // 这是发布 1.1 的 URL
script.css?v=1.2 // 等等
You can check out this

link to see how it works.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template