Opened 5 months ago
Last modified 5 weeks ago
#62261 new enhancement
Theme JSON: cached resolved URIs
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | has-patch has-unit-tests gutenberg-merge |
Focuses: | Cc: |
Description
A ticket to track the syncing of Gutenberg PR: https://github.com/WordPress/gutenberg/pull/66155
What
Implement "pretty basic caching" for resolved theme URIs in WP_Theme_JSON_Resolver::get_resolved_theme_uris
.
The intention to improve performance, even if slightly.
WP_Theme_JSON_Resolver::get_resolved_theme_uris
, and WP_Theme_JSON_Resolver::resolve_theme_file_uris
which calls it, is fired multiple times in a single session to:
- Generate styles
- Deliver resolved URIs in a global styles controller response.
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.
Syncing https://github.com/WordPress/gutenberg/pull/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 results (higher response time is worse):
|
|
|
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
Run
npm run test:unit:php:base -- --filter WP_Theme_JSON_Resolver_Gutenberg_Test
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: