[wp-trac] [WordPress Trac] #59719: Revise caching approach for theme files
WordPress Trac
noreply at wordpress.org
Mon Jan 8 20:57:01 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:18 joemcgill]:
> This is one of the reasons that I feel pretty strongly that any caching
needs to include a TTL expiration so that sites don't get stuck in a
broken state due to a stale cache indefinitely.
It is worth noting that theme cache already has a TTL on it. The
[https://github.com/WordPress/wordpress-
develop/blob/71cb3f861573f065c6d7d7ef1975bf98532239b4/src/wp-includes
/class-wp-theme.php#L236C37-L236C41 cache_expiration] is 1800. I would
like to see this filterable.
> 2. When someone has edited the theme from the Theme File Editor
Also worth noting that theme caches are already invalidated when using
Theme File Editor. See
[https://developer.wordpress.org/reference/functions/wp_edit_theme_plugin_file/
wp_edit_theme_plugin_file] and these [https://github.com/WordPress
/wordpress-develop/blob/71cb3f861573f065c6d7d7ef1975bf98532239b4/src/wp-
admin/includes/file.php#L648-L650 lines]. Caches are also invalidated when
themes are deleted, see
[https://developer.wordpress.org/reference/functions/delete_theme/
delete_theme] and these [https://github.com/WordPress/wordpress-
develop/blob/71cb3f861573f065c6d7d7ef1975bf98532239b4/src/wp-
admin/includes/theme.php#L130-L131 lines]. Caches are already invalidated
core / plugins / themes are updated when wp_clean_themes_cache is called.
We should make sure that all cache invalidation happens in the
[https://developer.wordpress.org/reference/classes/wp_theme/cache_delete/
WP_Theme::cache_delete()] method. This is called
[https://github.com/search?q=repo%3AWordPress%2Fwordpress-
develop+-%3Ecache_delete+&type=code throughout] core and likely by
[https://www.wpdirectory.net/search/01HKNDQ3Z1XXF4AMG2XA8P12RW third party
plugins].
Until we "solved" the cache invalidation problem, we CANNOT use
`site_transient` functions to cache this data. I have outlined a fix
[https://core.trac.wordpress.org/ticket/59719?replyto=18#comment:17 here],
but I am open to other ideas.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59719#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list