Round-Trip Cache Bfcache

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.