The Chrome team is actively experimenting with Back/Forward Cache for desktop and I wanted to call out some behavioral changes that extensions will experience with the WebNavigation API beginning in M92.
The changes match behaviorally what Mozilla has shipped in Firefox with its implementation, so we hope that we are following a well lit path.
Extensions will receive onBeforeNavigate, onCommited and onCompleted events when a page is restored from the Back/Forward cache but not the onDOMContentLoaded event. This is because the DOM content has already been loaded on the page.
The normal event flow is as follows:
First Navigation:
onBeforeNavigate -> onCommitted -> onDOMContentLoaded -> onCompleted
Restoring Navigation from Back/Forward Cache:
onBeforeNavigate -> onCommitted -> onCompleted
When a page is restored from the Back/Forward Cache, an extension may see a previous webNavigation event again. So care must be taken not to apply an operation to a page multiple times. For example, an extension which darkens a page in the onCompleted event should take care to not apply the operation a second time when the page is restored from the Back/Forward Cache. There are a few solutions to this behavior such as using the onDOMContentLoaded event which fires only when the page first loads or storing some state in the content script injected on the page.
If you wish to enable Back/Forward Cache and enable extension support you can launch chrome from the command line with the following flags:
--enable-features=BackForwardCache:content_injection_supported/true/all_extensions_allowed/true/TimeToLiveInBackForwardCacheInSeconds/180
These instructions will likely change in the future, but we will try to reply to this thread if they do update. To verify something is in the Back/Forward Cache check chrome://process-internals/#web-contents
Experimentation with Back/Forward Cache should begin in M92 releases in various channels. Please reach out via email or crbug.com if you find any issues or have concerns.
dave.
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CAHgVhZXqeivaHtbCRbqfO3M1dLgFT23SsBhBP_KRVgyp71YTDw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CAHgVhZXw-Jq4MnrGaiNZJsbGLxfY7wrm2grECsFu%2BAQv0Bcp3A%40mail.gmail.com.