[wp-trac] [WordPress Trac] #59719: Revise caching approach for theme files

WordPress Trac noreply at wordpress.org
Wed Jan 17 00:33:55 UTC 2024


#59719: Revise caching approach for theme files
-------------------------+--------------------------
 Reporter:  flixos90     |       Owner:  joemcgill
     Type:  enhancement  |      Status:  assigned
 Priority:  high         |   Milestone:  6.5
Component:  Themes       |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  2nd-opinion  |     Focuses:  performance
-------------------------+--------------------------

Comment (by spacedmonkey):

 Replying to [comment:21 flixos90]:
 > @joemcgill @spacedmonkey I concur that there should be a TTL on these
 caches. We could use the 1800s (30 minutes) that is already used on the
 `themes` cache (if configured to be persistent), that would keep the
 default consistent. We could then introduce a filter for it.

 It is worth noting that this value is already filtable. See these
 [https://github.com/WordPress/wordpress-
 develop/blob/bfcf2936dbd472fdcde7af84ddd16bbc3d63fb89/src/wp-includes
 /class-wp-theme.php#L253-L264 lines]. If you use
 `wp_cache_themes_persistently` filter and pass a int, it will change this
 value.

 {{{#!php
 add_filter('wp_cache_themes_persistently', function(){
   return DAY_IN_SECONDS;
 });
 }}}

 This will set `self::$cache_expiration` to a day. This functionality
 should be documented better.

 @flixos90 I outlined using cron to do cache invalidation in this
 [https://core.trac.wordpress.org/ticket/59719?replyto=21#comment:17
 comment]. What do you think?

 I have created a [https://github.com/wp-cli/extension-command/issues/392
 issue] on WP CLI, for a cache clear command for themes.

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


More information about the wp-trac mailing list