-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Theme JSON: cached resolved URIs #7596
base: trunk
Are you sure you want to change the base?
Theme JSON: cached resolved URIs #7596
Conversation
Theme JSON: cached resolved URIs
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
@@ -860,7 +871,13 @@ public static function get_resolved_theme_uris( $theme_json ) { | |||
return $resolved_theme_uris; | |||
} | |||
|
|||
$theme_json_data = $theme_json->get_raw_data(); | |||
$theme_json_data = $theme_json->get_raw_data(); | |||
$resolved_theme_uris_cache_key = md5( wp_json_encode( $theme_json_data ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be premature.
Looks like there's a small impact on performance on TT4
https://github.com/WordPress/wordpress-develop/actions/runs/11432958553?pr=7596
I'll run again as the tests vary between commits, e.g., https://github.com/WordPress/wordpress-develop/actions/runs/11432437736?pr=7596
Syncing WordPress/gutenberg#66155
Trac ticket: https://core.trac.wordpress.org/ticket/62261
What?
Implement "pretty basic caching" for resolved theme URIs in
WP_Theme_JSON_Resolver::get_resolved_theme_uris
.Why?
The intention to improve performance, even if slightly.
WP_Theme_JSON_Resolver::get_resolved_theme_uris
, andWP_Theme_JSON_Resolver::resolve_theme_file_uris
which calls it, is fired multiple times in a single session to:Here are some preliminary, but pretty inconclusive performance results (higher response time is worse):
I'd expect results will become more pronounced as other relative paths are introduced, e.g., fonts, and more blocks support background images.
Cached data is not be stored persistently across page loads.
How?
Simple object caching.
Testing Instructions
PHP CI tests should pass.
Create a theme.json with background image paths defined for several blocks.
Ensure these appear as expected in the editor and frontend.
In the theme.json file, replace one or several paths with new asset paths. Check that the styles have been updated and the editor/frontend looks good.
Here is some test JSON based on current assets in TT5: