How to completely disable html and element resource caching?

because I am a Wechat H5 developer, I often encounter the problem of using debugx5.qq.com to clean the cache, but the iOS cannot be cleared, so I have to log in to Wechat again.

I know that caching can be avoided by adding a timestamp, but if the access address is fixed, how to ensure that each access is a new address?

in addition, what is the better way to handle the caching of script tags, link tags and img tags within html, because if js is written to the bottom of body, the dom is rendered and the request should be sent? will the second request be sent if you use js to modify the suffix ? t = timestamp ? But if you write it in head, and dom hasn"t rendered yet, you can"t get the elements inside. Is there a good solution?

May.31,2022

you can insert < script > tags dynamically


using the HTTP proxy server, modify HTTP response header to disable caching.

such as

  • Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate

write a QR code generator.
put the home address in to automatically generate QueryString to avoid browser cache sweep access to the file.

as for the connected resource file connection, the js encapsulation method is used to dynamically load it, adding the QueryString parameter. Or use tools to deal with it.

< H2 > reason < / H2 >

because sometimes Wechat caches not only the resource file but also the entire page, so it generates a dynamic QR code alone.

< H2 > other < / H2 >

use Chrome to connect to Wechat browser and use Ctrl + F5 to refresh the page.

Menu