When setting up openings, animations, etc. for a website or web application, it is recommended that the flags that control whether they are played or not be stored in persistent objects such as
sessionStorage or
localStorage
.
This is because if JavaScript alone is used to make the decision, fbcache and other such objects
may come into play, and the application may not work as expected.
fbcache is an in-memory cache used by the Safari browser. It stores a complete snapshot of the page (including the JavaScript heap) when the user is navigating. Because the entire page is stored in memory, the browser can quickly and easily restore the page if the user decides to return.
fbcache is designed to improve the user experience by making the back/forward buttons more efficient For example, if a user navigates through a page and then clicks on the back/forward button, the page is restored. For example, if a user navigates through a page and then clicks the back button, the browser can restore the page from fbcache and return the user to the previous page. This eliminates the need for the user to load the page from scratch and reduces loading time.
fbcache also caches the JavaScript heap. This means that if the user navigates to a page and then needs to execute JavaScript, the browser can pull the JavaScript heap from fbcache and return the user to the previous page. This improves performance because the user does not have to re-execute the JavaScript.
SessionStorage and
localStorage
, on the other hand, can store information in the browser and retain its value even when the page is reloaded or revisited. This makes it easier to manage replay flags and prevent unexpected behavior.