In many businesses, we operate from a page, after entering the B page to display the results of the operation, when we directly back to the a page, we need a page can automatically refresh the data, but the a page has not changed. That is, the page is refreshed after the return, which is the round-trip cache Back-forward cache (referred to as Bfcache).
Bfcache, the Back-forward cache, can be called "round-trip caching" to speed up the conversion of pages when users use the browser's back and forward buttons. This cache not only saves the page data, but also preserves the state of the DOM and JS, actually keeping the entire page in memory. If the page is in Bfcache, then opening the page again will not trigger the OnLoad event.
Pageshow Events
This event is triggered when the page is displayed, regardless of whether the page is from Bfcache. In the reload page, Pageshow fires after the load event is triggered, and for pages in Bfcache, Pageshow is triggered at the moment the page state is fully restored.
Window.addeventlistener (' Pageshow ', function (e) {appendfunc ("Pageshow Event"); Appendfunc ("Pageshow persisted is:" + e.persisted);})
The above methods can be violent if they are used:
if (window.name! = "Fresh") { location.reload (); Window.name = "Fresh";} else{ window.name = "";}
Round-Trip Cache Bfcache