[wp-trac] [WordPress Trac] #59719: Revise caching approach for theme files
WordPress Trac
noreply at wordpress.org
Wed Jan 3 21:59:15 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):
Cache invalidation with themes is extremely hard. Theme files of all types
can be updated at any time. Theme files can be updated in the following
ways.
- Files are editted on file system, via FTP or SSH. There is no PHP event
/ action for this. File edit time (may be) updated.
- Files are overwritten using a tool like git/rsync or cp. There is no PHP
edit for this. File edit time (may be) updated.
- Files are editted in the CMS using the theme editor. There is PHP event
or action here. This is unpopular way of editing files and is disabled on
many hosts.
- Updating theme via plugin repo. There is a currently cache invalidation
and a PHP event there.
In instances where files are directly edited, the absence of a PHP event
complicates cache invalidation, leading to potential issues such as
incorrectly cached files. Fixed time cache settings are also deemed
unsuitable, as immediate theme updates are expected without delay.
The use of functions like filemtime is hindered on cloud servers. For
example, in a scenario with multiple web servers deployed simultaneously,
the last update date would be identical. However, introducing or replacing
a server could result in differing last update dates, causing cache
invalidation even when no files were modified. This situation may further
lead to inconsistent cache values.
To address these challenges, a proposed solution includes the introduction
of a WP CLI command for theme cache clearance, allowing hosts and
developers to force cache clears upon code deployment:
`wp theme cache twentyten clear`
This command empowers hosts and developers to force cache clears upon code
deployment, ensuring timely updates across web servers. Additionally,
incorporating a theme cache clear button in the CMS interface offers a
user-friendly alternative.
To address the unique workflow of hosts like VIP GO, adhering to a git-
based deployment, an optional constant can be introduced. This constant,
when set, signals that theme files are immutable on the file system. Large
hosts capable of supporting this feature can opt in, simplifying cache
invalidation steps post-code deployment, as exemplified by the WP CLI
command mentioned earlier.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59719#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list