Download the PHP package cpsit/typo3-cache-bags without Composer
On this page you can find all versions of the php package cpsit/typo3-cache-bags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cpsit/typo3-cache-bags
More information about cpsit/typo3-cache-bags
Files in cpsit/typo3-cache-bags
Package typo3-cache-bags
Short Description TYPO3 CMS extension to build and register cache bags for enhanced cache control
License GPL-2.0-or-later
Informations about the package typo3-cache-bags
An extension for TYPO3 CMS to build and register cache bags for enhanced cache control. Cache bags are built during runtime on uncached contents and can be used to define cache metadata like cache tags. In addition, they are used to calculate expiration dates for specific cache entries. This allows are fine-grained cache control, depending on the contents and their explicit dependencies like specific database contents or short-living API requests.
🚀 Features
- Interface for cache bags with different cache scopes (e.g. pages)
- Cache bag registry to handle generated cache bags
- Cache expiration calculator for various use cases (query builder, query result etc.)
- Event listener to override page cache expiration, based on registered page cache bags
- Compatible with TYPO3 11.5 LTS, 12.4 LTS and 13.4 LTS
🔥 Installation
Composer
TER
Alternatively, you can download the extension via the TYPO3 extension repository (TER).
⚡ Usage
Cache bags
A cache bag can be seen as some type of metadata collection for a specific cache scope, e.g. for the current page (Frontend-related cache). It is used to control the cache behavior within a given scope, for example by defining custom cache tags or an explicit expiration date.
At the moment the following cache bags are supported:
Cache bag | Scope |
---|---|
Cache\Bag\PageCacheBag |
Enum\CacheScope::Pages |
[!TIP] You can also add your own cache bags by implementing
Cache\Bag\CacheBag
.
Here is an example about how to generate a new PageCacheBag
for a given page:
Cache bag registry
In order to actually use a generated cache bag, each bag must be registered in
the global Cache\Bag\CacheBagRegistry
.
This registry is defined as singleton instance and stores all registered cache
bags during runtime.
The CacheBagRegistry
should be injected using dependency injection or, if
DI is not possible, by using GeneralUtility::makeInstance()
:
Dispatched events
When adding a new CacheBag
to the registry, a
CacheBagRegisteredEvent
is
dispatched. It is used, for example, to apply cache tags to the current
Frontend request (using the shipped
PageCacheBagRegisteredEventListener
).
Get closest expiration date
Based on all registered cache bags, the registry is able to calculate the closest expiration date (if any cache bag provides an expiration date) for a given cache scope:
This is used, for example, to apply the expiration date to the current Frontend
page cache (using the shipped PageCacheLifetimeEventListener
for TYPO3 ≥ v12 and PageCacheTimeoutHook
for TYPO3 v11).
Cache expiration calculator
As already mentioned, cache bags may also store the expiration date of a
targeted cache entry. The extension ships with a
Cache\CacheExpirationCalculator
that can be used to calculate an expiration date. The calculation is based
on various input methods. At the moment, the following methods are available:
- Calculation based on an Extbase query or query result
- Calculation based on a Query Builder instance
- Calculation based on an initialized Relation Handler
Full example
Typical use cases of cache bags are list and detail views of custom records
in Frontend scope. Here is a full example about how to use the PageCacheBag
in list and detail views of a custom table:
🧑💻 Contributing
Please have a look at CONTRIBUTING.md
.
💎 Credits
The extension icon ("container") is a modified version of the original
actions-container
icon from TYPO3 core which is originally licensed
under MIT License.
⭐ License
This project is licensed under GNU General Public License 2.0 (or later).
All versions of typo3-cache-bags with dependencies
psr/event-dispatcher Version ^1.0
psr/http-message Version ^1.0 || ^2.0
typo3/cms-core Version ~11.5.0 || ~12.4.0 || ~13.4.0
typo3/cms-extbase Version ~11.5.0 || ~12.4.0 || ~13.4.0
typo3/cms-frontend Version ~11.5.0 || ~12.4.0 || ~13.4.0