Skip to content

Conversation

5mehulhelp5
Copy link
Contributor

@JaJuMa @GrimLink @rhoerr please check and let me know if you found any suggestion on that

@rhoerr
Copy link
Contributor

rhoerr commented Oct 10, 2025

If I understand the code correctly:

  • If it's a bfcache traversal, initialize the BFCacheHandler immediately
  • Otherwise, set an event on when the page is actually opened (prerenderingchange or visibilitychange) and wait until then to initialize BFCacheHandler
  • ? This prevents speculation rules in prerender mode from taking a bfcache snapshot before the page is opened and using it for the speculation load ?

Is that correct? Or is there more to it?

Note that with the upcoming new release the default speculation mode here will change from prerender to preload, which should not have the state issue you mentioned (where changes to cart status won't show up on pages previously prerendered).

}, { passive: true });
// 2️⃣ Chrome / Edge — prerendering API
if ('prerendering' in document || 'onprerenderingchange' in document) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a page is loaded without prerendering in Chrome/IE, does this prevent bfcache from initializing at all?

@JaJuMa
Copy link
Contributor

JaJuMa commented Oct 13, 2025

@5mehulhelp5

I was also able to reproduce this issue, it happens when the product page was prerendered right before adding the item to the cart. In that case, the product page displays outdated content.

We’ve implemented this function to handle that situation in the BFcache template: actionRefreshMiniCart().

In my opinion, the logic for handling this issue should be placed in the speculation-rules.phtml template instead of the bfcache/handler.phtml.
Also, it might be worth considering fixing this for both the Luma and Hyvä themes.

Please review this approach and let me know your thoughts.

Thanks

@rhoerr rhoerr added the question Further information is requested label Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants