Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: #93436 - Introduce cache:warmup console command #4413

Open
simonschaufi opened this issue Oct 30, 2024 · 0 comments
Open

Feature: #93436 - Introduce cache:warmup console command #4413

simonschaufi opened this issue Oct 30, 2024 · 0 comments

Comments

@simonschaufi
Copy link
Collaborator

Feature: #93436 - Introduce cache:warmup console command

https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.4/Feature-93436-IntroduceCacheWarmupConsoleCommand.html

Feature: #93436 - Introduce cache:warmup console command

See 93436

Description

It is now possible to warmup TYPO3 caches using the command line.

The administrator can use the following CLI command:

./typo3/sysext/core/bin/typo3 cache:warmup

Specific cache groups can be defined via the group option. The usage is
described as:

cache:warmup [--group <all|system|di|pages|>]

All available cache groups can be supplied as option. The command
defaults to warm all available cache groups.

Extensions that register custom caches are encouraged to implement cache
warmers via TYPO3\CMS\Core\Cache\Event\CacheWarmupEvent.

Note: TYPO3 frontend caches will not be warmed by TYPO3 core, such
functionality could be added by third party extensions with the help of
TYPO3\CMS\Core\Cache\Event\CacheWarmupEvent.

Impact

It is common practice to clear all caches during deployment of TYPO3
instance updates. This means that the first request after a deployment
usually takes a major amount of time and blocks other requests due to
cache-locks.

TYPO3 caches can now be warmed during deployment in release preparatory
steps in symlink based deployment/release procedures. This enables fast
first requests with all (or at least system) caches being prepared and
warmed.

Caches are often filesystem relevant (filepaths are calculated into
cache hashes), therefore cache warmup should only be performed on the
live system, in the final folder of a new release, and ideally before
switching to that new release (via symlink switch). Note that caches
that have be pre-created in CI will likely be useless as cache hashes
will not match.

To summarize: Cache warmup is to be used during deployment, on the live
system server, inside the new release folder and before switching the
new release live.

Deployment steps are:

  • Release preparation:
    • git-checkout/rsync your codebase (on CI or on live system)
    • composer install (on CI or on live
      system)
    • vendor/bin/typo3 cache:warmup --group
      system
      (only on the live system)
  • Change release symlink to the new release folder
  • Release postparation
    • Clear only the page related caches (e.g. via database truncate or an
      upcoming cache:flush command)

The conceptional idea is to warmup all file-related caches before
(symlink) switching to a new release and to only flush database and
frontend (shared) caches after the symlink switch. Database warmup could
be implemented with the help of the
TYPO3\CMS\Core\Cache\Event\CacheWarmupEvent as an additionally
functionality by third party extensions.

Note that file-related caches (summarized into the group "system") can
safely be cleared before doing a release switch, as it is recommended to
keep file caches per release. In other words, share var/session,
var/log, var/lock and var/charset between releases, but keep
var/cache be associated only with one release.

CLI, ext:core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant