[wp-trac] [WordPress Trac] #56910: Improve caching in `wp_get_global_stylesheet`

WordPress Trac noreply at wordpress.org
Thu Jan 26 22:57:38 UTC 2023


#56910: Improve caching in `wp_get_global_stylesheet`
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:  flixos90
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  6.2
Component:  Editor                               |     Version:  5.9
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests gutenberg-  |     Focuses:
  merge commit                                   |  performance
-------------------------------------------------+-------------------------

Comment (by flixos90):

 A final brief performance benchmark on this one:
 * The use of WP cache API makes the code more performant than when using a
 transient, for when the value for the transient is not set (~4.5ms
 compared to ~8.8ms).
 * When the transient has a value set, it is of course much faster than the
 WP cache API since we are now using a non-persistent cache (~0.6ms
 compared to ~4.5ms).

 This is expected since the transient is cached between requests, making
 subsequent lookups much faster - however it's only cached for 1 minute,
 which is a hacky approach to get some sort of "semi-persistent" cache for
 something where we haven't yet figured out cache invalidation.

 Overall the function is called only 1 time per regular page load, so the
 non-persistent cache here does not improve performance. However, it still
 makes more sense than the transient due to the above. As we are working
 towards a persistent cache solution, this is a step in the right
 direction, even though performance-wise it is a zero-sum game.

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


More information about the wp-trac mailing list