Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Lehmann committed Jan 12, 2023
0 parents commit b977ead
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Classes/Hooks/CreateHashBaseHook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Networkteam\CacheBase\Hooks;

use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

class CreateHashBaseHook
{
public function addVariables($params, TypoScriptFrontendController $typoScriptFrontendController)
{
$params['hashParameters']['networkteam_cachebase'] = $GLOBALS['EXTCONF']['networkteam_cachebase']['keys'];
}
}
33 changes: 33 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# TYPO3 Extension networkteam_cachebase

In container environments with rolling updates there is the point where two versions run parallel and a page cache flush
is not what we want.

## What does it do?

This extension adds variables to the page cache identifier calculation. For our Use Case it adds the
environment variable `SENTRY_RELEASE`, which contains a version number.

More variables can be added like

```php
$GLOBALS['EXTCONF']['networkteam_cachebase']['keys']['your_key'] = 'value';
```

## Installation

```shell
composer req networkteam/typo3-cachebase
```

## Background

The page cache hash calculation is based on

* Page row
* TypoScript Conditions
* Modification time of loaded TypoScript files
* Site
* ... and some more

but changes for example in Fluid Templates are not taken into account.
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "networkteam/typo3-cachebase",
"type": "typo3-cms-extension",
"description": "It adds variables to the page cache identifier calculation for serving multiple versions of a webseite parallel. This is the case in container environments with rolling updates.",
"license": "GPL-2.0-or-later",
"keywords": [
"caching",
"container"
],
"authors": [
{
"name": "networkteam",
"email": "typo3@networkteam.com"
}
],
"autoload": {
"psr-4": {
"Networkteam\\CacheBase\\": "Classes/"
}
},
"require": {
"typo3/cms-core": "^11.5 || ^12.0"
},
"extra": {
"typo3/cms": {
"extension-key": "networkteam_cachebase"
}
}
}
6 changes: 6 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$GLOBALS['EXTCONF']['networkteam_cachebase']['keys']['sentry_release'] = getenv('SENTRY_RELEASE');

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'][]
= \Networkteam\CacheBase\Hooks\CreateHashBaseHook::class . '->addVariables';

0 comments on commit b977ead

Please sign in to comment.