GreenIT | V2 | V3 | V4 |
---|---|---|---|
28 | 5 | 7 |
Life cycle | Tiers | Responsible |
---|---|---|
2. Design | User / Device | UX/UI Designer |
Priority | Implementation difficulty | Ecological impact |
---|---|---|
3 | 4 | 3 |
Ressources saves |
---|
Processor / Network |
The browsers have a feature of fast navigation in the history (previous page and next page buttons), called back-forward cache or bfcache.
Contrary to the HTTP cache which makes it possible to keep in memory the responses to the requests previously sent and to speed up the re-loading of these pages, the bfcache cache allows the browser to store an entire page in memory. However, as the use of this feature requires additional machine resources on the user side, it's interesting to reduce the functionalities of the pages stored with the bfcache as much as possible. Moreover, the use of bfcache implies some caution, especially when the waiting time is exceeded (setTimeout). Indeed, as browsers suspend the execution of pending timers and tasks in JavaScript queues, and resume it when the page is restored from the bfcache, there may be problematic situations. For example, if the browser suspends a task required as part of an IndexedDB transaction or API usage and other tabs (using the same IndexedDB database) are open at that time, the browser will not cache individual pages.
Any element that would make the page ineligible for bfcache and/or which would render the page unusable after leaving it should be avoided.
Avoid :
- actions triggered when leaving the page (
unload
orbeforeunload
events, preferpagehide
if it is really necessary) - links that open new tabs / windows without
rel="noopener"
orrel="noreferrer"
- leave connections (IndexedDB,
fetch()
ou XMLHttpRequest, Web Sockets, etc.) open when the user leaves the page
Use the pageshow
and/or pagehide
events to reset the elements that require it : e.g. re-enable form buttons that
deactivate upon submission, delete sensitive information (such as passwords), or to close/reopen persistent connections.
Source:
- https://web.dev/bfcache/ (content under CC BY 4.0 licence - Back/forward cache from Philip Walton)
The number of ... | is equal to or less than |
---|---|
pages ineligible to bfcache | 0% |