[wp-trac] [WordPress Trac] #59719: Revise caching approach for theme files
WordPress Trac
noreply at wordpress.org
Mon Jan 15 18:22:28 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 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.
The TTL will help work around the limitations of cache invalidation, which
is impossible to reliably solve when editing theme files in non-standard
ways. With a 30 minute TTL, changes will still reflect after a short time.
If immediate invalidation is needed, this can be achieved in one of two
ways:
* Either flush the cache, or the specific cache group, or flush
transients. This would be most relevant when deploying/uploading a new
version of the theme, and you don't want to wait for 30 minutes.
* Or use `WP_DEVELOPMENT_MODE` to bypass caching entirely. This would be
most relevant when actually developing the theme (e.g. locally). There you
definitely don't want to wait for changes to be reflected, and that's
specifically what that constant is for.
I agree with the proposed group names `themes` (already present anyway),
`theme_json`, and `theme_files`. There are at least two crucial ways in
which `theme_json` and `theme_files` differ (and thus, why they need to be
distinct groups):
* `theme_json` includes potentially user-generated / user-modified data,
so it cannot be global. `theme_files` on the other hand only includes data
that comes entirely from the filesystem.
* `theme_json` uses cache keys that are always for the ''current'' theme,
where for `theme_files` we envision the keys to include theme slugs and be
global.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59719#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list