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 #1

Updated by Mathias Schreiber about 8 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Mathias Schreiber

You are correct in this case but we wonder how you call TSFE multiple times during one request?
The nature of the cache is that it should only exist during runtime, thus under normal conditions should not be called for multiple pages.

Can you give us some insights on your setup so we can investigate?

Actions #2

Updated by Mathias Schreiber about 8 years ago

After checking back we came to the following conclusion:

a) why is a runtime cache configurable at all?
b) is a runtime cache the correct caching strategy here?

Actions #3

Updated by Alexander Opitz over 7 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions

Also available in: Atom PDF