Project

General

Profile

Actions

Bug #75322

closed

Wrong cache lifetime calculation

Added by Stefan Isak about 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Should have
Category:
Caching
Target version:
-
Start date:
2016-03-30
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
cache
Complexity:
Is Regression:
No
Sprint Focus:

Description

To me it seems that get_cache_timeout() calculates wrong cache lifetimes.

frontend/Classes/Controller/TypoScriptFrontendController.php (TYPO3 7.6.4):
4424 /**
4425 * Get the cache timeout for the current page.
4426 *
4427 * @return int The cache timeout for the current page.
4428 */
4429 public function get_cache_timeout()
4430 {
4431 /** @var $runtimeCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
4432 $runtimeCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime');
4433 $cachedCacheLifetimeIdentifier = 'core-tslib_fe-get_cache_timeout';
4434 $cachedCacheLifetime = $runtimeCache->get($cachedCacheLifetimeIdentifier);
4435 if ($cachedCacheLifetime === false) {
[...]
4467 }
4468 return $cachedCacheLifetime;
4469 }

Line 4433 sets the same cache identifier for every request. So the first page warming up the cache defines the cache lifetime of all subsequent requests. Therefore it's not like the methods comment suggests "Get the cache timeout for the current page.".

One can understand the effect creating two pages and set a different page lifetime for one of them. Now perform a request for both pages and they'll always have the same cache lifetime, the lifetime of the first page requested.

To achieve what the method actually wants to do, the cache identifier needs to be different, e.g. $cachedCacheLifetimeIdentifier = 'core-tslib_fe-get_cache_timeout-' . $this->id;.

Actions

Also available in: Atom PDF