For single-page applications built with webpack, index.html is cached so that each update has to be refreshed to get the latest code.

A single-page application made with react+webpack, and then every time you update the code with cdn, you swipe cdn, but the user opens the browser directly to visit the site, still using the old code, but the page can be refreshed. At this time, close the browser and open it again, or you will only access the old code. I want index.html as an entry not to be cached by the browser, and to get the latest code every time, what to do.

Mar.16,2021

then you need to set it on cdn. It should be


that you can turn off the cache of specified files. I also met. Did the landlord solve


?


I have a solution here, which is to add random string parameters to the index page. Similar to: https://baidu.com/index?v=ran.

roughly means something like this:

when we request an index page, we add a random request version to it, so that we can communicate with the server, thus solving the problem that the index page is cached.

Menu