[wp-trac] [WordPress Trac] #59595: Improve performance of WP_Theme_JSON::compute_style_properties

WordPress Trac noreply at wordpress.org
Fri Jul 12 16:06:39 UTC 2024


#59595: Improve performance of WP_Theme_JSON::compute_style_properties
-----------------------------------------+--------------------------
 Reporter:  spacedmonkey                 |       Owner:  thekt12
     Type:  enhancement                  |      Status:  reopened
 Priority:  normal                       |   Milestone:  6.6
Component:  Editor                       |     Version:  5.8
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch changes-requested  |     Focuses:  performance
-----------------------------------------+--------------------------

Comment (by joemcgill):

 I can also confirm the issue reported by @andrewserong.
 [https://github.com/WordPress/wordpress-develop/pull/7017 PR #7017] fixes
 the issue by including a hash of the block styles data with each block
 node, which will invalidate the cached styles for each block individually
 if that data changes.

 Rather than splitting the responsibility for cache invalidation to both
 the hash stored as part of the transient name and also a hash saved as
 part of the transient data, I propose we consider the approach in
 [https://github.com/WordPress/wordpress-develop/pull/6879 PR #6897], which
 I've just updated so it's ready for review.

 The major changes in my alternate approach are:

 1. Uses a hash of the entire raw Theme JSON data for cache invalidation.
 2. Saves the hash as part of the saved data rather than as part of the
 transient name, to make manual clearing of the transient easier (e.g., `wp
 transient delete wp_styles_for_blocks`.
 3. Changes cache storage from using `{get|set}_site_transient()` to
 `{get|set}_transient`, so that each site on a network has an individual
 cache, rather than storing all caches at the network level when running as
 a multisite. This addresses a separate concern that I had noticed while
 reviewing the performance of the current approach (comment:61), but would
 be good to fix at the same time.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59595#comment:75>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list