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. |
|
|
||
| $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.
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
|
Closing as stale. |
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_uriswhich 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:
{ "$schema": "../../schemas/json/theme.json", "version": 3, "settings": { "appearanceTools": true }, "styles": { "background": { "backgroundImage": { "url": "file:./assets/images/category-anthuriums.webp" } }, "blocks": { "core/group": { "background": { "backgroundImage": { "url": "file:./assets/images/category-cactus.webp" } } }, "core/post-content": { "background": { "backgroundImage": { "url": "file:./assets/images/hero-podcast.webp" } } }, "core/quote": { "background": { "backgroundImage": { "url": "file:./assets/images/category-sunflowers.webp" } } }, "core/pullquote": { "background": { "backgroundImage": { "url": "file:./assets/images/dallas-creek-square.webp" } } } } } }