Reputation: 11
I recently found out about BFCache and how it affects web analytics tools. To find out how big of an issue this is on my website, I implemented the solution from web.dev. I added a custom dimension to see if a pageview is fired through this new event listener or through a 'normal' pageview and I also added a custom dimension to see the status of performance.navigation.type
(I know it's deprecated but so far it's still working). To my surprise, I got an uplift of about 3.5%, meaning that for one day where I had the solution implemented, 3.5% of pageviews were fired through the pageshow event.
BUT: in about 5% of those cases, both the pageshow event as well as the normal pageview event fired a pageview. And even more interesting: in most of those cases, first the pageshow-pageview fired, and then, shortly after, the normal pageview fired, the latter containing "0" as the navigation type instead of "2" as one would expect. So it seems that in some cases, the javascript of the cached page is triggered again when the page is loaded from the cache, with all of the page info being as it was when the page was put into the cache(e.g. navigation type being "0").
I managed to recreate this behaviour in my safari browser, but I only by coincidence as I failed to see a pattern behind when a second 'normal' pageview is fired and when not.
So, long story short: Any ideas why safari would re-execute javascript when a page is loaded from it's BFcache?
Upvotes: 1
Views: 415