WICG / soft-navigations

Heuristics to detect Single Page Apps soft navigations
https://wicg.github.io/soft-navigations/
Other
46 stars 6 forks source link

[Question] BF cache #17

Closed Smrtnyk closed 1 year ago

Smrtnyk commented 1 year ago

Is the softnavigation entry supposed to be triggered also on bf cache restores?

tunetheweb commented 1 year ago

No it is not. There is separate work going on in that area which may trigger a similar navigation but it should not trigger a soft navigation (as it currently doesn't trigger a hard navigation either).

Smrtnyk commented 1 year ago

So in case of bf cache page restore, we should calculate manually fid, lcp, fcp? since there will be no such paint timing entries correlated to the navigation entry(since there is none)? but in following scenario:

  1. page restored from bf cache -> no fid, lcp, fcp triggered
  2. soft nav occurs -> browser will capture again fid, lcp, fcp?
tunetheweb commented 1 year ago

Correct. Think of the bfcache as just restoring the page as if you hadn't navigated away.

So in that case a soft nav happening without navigating away and the bfcache restore, would emit soft nav entries. So it also should continue to do it for any future soft navs after a bfcache restore.

yoavweiss commented 1 year ago

Thanks @tunetheweb. Closing but feel free to reopen if there are further unanswered questions.

DerGernTod commented 1 year ago

I think it's really important to address this topic, especially since Google themselves recommend treating back-forward cache restores as separate page views. You can find more information about it in this helpful article from Google: https://web.dev/bfcache/#how-bfcache-affects-analytics-and-performance-measurement.

I completely agree that, from a JavaScript engine perspective, it may seem like nothing happened. However, that's not really relevant, especially when it comes to soft navigations. When a page is restored from the bfcache, it is definitely considered a navigation (whether it's a hard or soft one) because the user has moved from another page to the current one. Even though the engine seamlessly continues where it left off, for the user, it feels like a completely new page view.

Let's imagine a scenario in a webshop where you're browsing through a list of items. You touch one of them on your phone to see the details and then go back to continue scrolling. In this case, factors like the first input delay are definitely important. The performance of the bfcache restore plays a crucial role in such situations. Does the page load new data upon a bfcache restore? Does it take too long to do so?

Citing the Google blog post:

[...] you can report bfcache restores as pageviews (recommended) by listening to the pageshow event and checking the persisted property.

Therefore, it is actually recommended by Google to treat bfcache restores as page views, and imho this aligns directly with the concept of a (soft) navigation.

Since this proposal is from Google, I wonder if the recommendations of the blog post are outdated (I don't think so, because the article has been updated just a week ago), or did Google change their point of view regarding bfcache and page views?

Smrtnyk commented 1 year ago

I agree with everything that @DerGernTod wrote above

There is separate work going on in that area

@tunetheweb is there any resource about this you can link?

@yoavweiss unfortunately I cannot reopen because there is no button for that, but would be good to clarify some things here