Why doesn't the browser read the cache when it returns?

scenario:
users purchase goods, payment interface, there is a countdown. Click to pay and then go back, and the countdown still stays at the time when the page was refreshed for the first time.

I said that when the browser"s disable cache is selected and do the same operation again, the countdown is normal.

so how does the front end prohibit reading cache on return? Or prohibit some files from reading the cache?

Aug.15,2021

use post/ to add a useless random number or timestamp parameter


an easy way is to add a random string to the end of the URL, most commonly with the current date. For example, the only function of the random number parameter
url = "www.baidu.com?city=hangzhou&random=" + new Date (). GetTime ();
is to make the browser think that the request is a new link, so that the browser will not read the contents of the cache. In fact, the request is the same resource, but due to the addition of a random number parameter, the browser will think that the request is a different resource, so the browser will not read the contents of the cache, but directly access the server. However, there is a drawback, because caching can reduce direct access to the server and reduce the pressure on the server. After the browser does not read the contents of the cache, it will visit the server every time, which will increase the pressure on the server.


the above boss's plan is very good,
add personal experience:
1. In the case of using the js framework-destroy the component / page using lifecycle / routing. To achieve the default reload each time the url is accessed;
2. Not using the js framework-the js is rewritten as a closure, that is, each access to the self-call (reset) / countdown variable is not recorded;
3. Manually reset

Menu