[wp-trac] [WordPress Trac] #57789: Make theme.json related caches persistent
WordPress Trac
noreply at wordpress.org
Wed Feb 22 18:59:02 UTC 2023
#57789: Make theme.json related caches persistent
-------------------------+--------------------------
Reporter: flixos90 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 6.3
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: | Focuses: performance
-------------------------+--------------------------
Changes (by flixos90):
* milestone: Awaiting Review => 6.3
Old description:
> The `theme_json` cache group is currently non-persistent, which means
> that, even when a site uses a persistent object cache, the data in this
> cache group will only be cached ''within'' a single request. In other
> words, there is only a benefit to this caching when a function is called
> several times, at least more than once, in a single request.
>
> Needless to say, we have noticed in the past that parsing `theme.json`
> and running related logic can be expensive, and the preferable outcome
> would be to make those caches persistent so that they also can be cached
> beyond requests.
>
> The biggest challenge to this is to implement proper cache invalidation.
> Originally, within Gutenberg, the cache group was persistent, but it led
> to problems due to:
> * cache invalidation hard to figure out (what are all the events can lead
> to the cached values becoming stale?)
> * caching logic, rather than database values, is not yet a common
> practice in WordPress, and one of the quirks is that e.g. action/filter
> hooks may no longer be run when the logic that contains them is cached,
> which can lead to a clunky developer experience
New description:
The `theme_json` cache group is currently non-persistent, which means
that, even when a site uses a persistent object cache, the data in this
cache group will only be cached ''within'' a single request. In other
words, there is only a benefit to this caching when a function is called
several times, at least more than once, in a single request.
Needless to say, we have noticed in the past that parsing `theme.json` and
running related logic can be expensive, and the preferable outcome would
be to make those caches persistent so that they also can be cached beyond
requests.
The biggest challenge to this is to implement proper cache invalidation.
Originally, within Gutenberg, the cache group was persistent, but it led
to problems due to:
* cache invalidation hard to figure out (what are all the events can lead
to the cached values becoming stale?)
* caching logic, rather than database values, is not yet a common practice
in WordPress, and one of the quirks is that e.g. action/filter hooks may
no longer be run when the logic that contains them is cached, which can
lead to a clunky developer experience
See related comment
https://core.trac.wordpress.org/ticket/57648#comment:17
--
Comment:
This tracking ticket will likely involve several issues and PRs in the
Gutenberg repository to identify the best approach for the various usages
of caching related to `theme.json` and the `theme_json` cache group.
I'm hopeful we can at least make some notable progress here for WordPress
6.3, so I'll milestone it for that release for now, acknowledging though
that most of the work will need to happen in the Gutenberg repository, so
it'll probably be a while until we get a PR here.
cc @oandregal @spacedmonkey
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57789#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list