-
Notifications
You must be signed in to change notification settings - Fork 4.7k
iAPI Router: Update cached styles for re-fetched pages #75097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -24 B (0%) Total Size: 3 MB
ℹ️ View Unchanged
|
What?
Fixes the Interactivity API Router not updating styles when a cached page is re-fetched with
force: true.Why?
When
navigate( url, { force: true } )is called, thepagescache is correctly bypassed, and a fresh HTML fetch is triggered. However, the internalpreloadStyles()function maintained its ownstyleSheetCache, keyed by URL, which was never invalidated. The freshly fetched DOM's styles were completely ignored, and stale cached style references were returned instead.This meant that force-navigating to a previously visited page would not load any new styles, even if the HTML response included new blocks or new stylesheets. The page regions would update with the new content, but the corresponding styles would be missing.
How?
The PR removes
styleSheetCachefrompreloadStyles()entirely. This cache level is redundant, as pages are already cached with their corresponding Style elements. ThepreloadStyles()function would only be called for the same URL if that URL is being re-fetched withforce: true, in which case styles always need to be recomputed.Testing Instructions
@wordpress/interactivity-routermodule available in the console.@wordpress/interactivity-routermodule in the console.