Project

General

Profile

Actions

Bug #106065

closed

Too long X-TYPO3-Cache-Tags Header

Added by Pascal Geldmacher about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Caching
Target version:
-
Start date:
2025-02-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
13
PHP Version:
8.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I get an 500 Server error If I have the FE debug modus active and the X-TYPO3-Cache-Tags will set.
There is a page which has a array with 500 CacheTags. In the array are pages, sys_file, sys_file_metadata cachetags.

The middleware CacheDataCollectorAttribute generates the X-TYPO3-Cache-Tags header and run in a 500 error because the header is too long.

  public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Middlewares are shared services. With sub requests in mind, we need to take care
        // existing data of the parent request is not overwritten by a sub request. We thus
        // back up any existing data, create a new CacheDataCollector, dispatch the request,
        // and reset before returning the response.
        // @todo: We could argue sub requests should run their own container instance, but
        //        this has more impact and has not been sorted out, yet.
        $backup = $this->cacheDataCollector;
        $this->cacheDataCollector = new CacheDataCollector();
        $request = $request->withAttribute('frontend.cache.collector', $this->cacheDataCollector);
        $response = $handler->handle($request);
        if ($this->isDebugModeEnabled()) {
            $cacheTags = array_map(fn(CacheTag $cacheTag) => $cacheTag->name, $this->cacheDataCollector->getCacheTags());
            sort($cacheTags);
            $response = $response->withHeader('X-TYPO3-Cache-Tags', implode(',', $cacheTags));
            $response = $response->withHeader('X-TYPO3-Cache-Lifetime', (string)$this->cacheDataCollector->resolveLifetime());
        }
        foreach ($this->cacheDataCollector->getCacheEntries() as $deferredCacheItem) {
            $deferredCacheItem($request);
        }
        $this->cacheDataCollector = $backup;
        return $response;
    }

Related issues 1 (1 open0 closed)

Is duplicate of TYPO3 Core - Bug #105703: Premature end of script headers due to X-TYPO3-Cache-TagsUnder Review2024-11-26

Actions
Actions #1

Updated by Andreas Kienast about 1 month ago

  • Is duplicate of Bug #105703: Premature end of script headers due to X-TYPO3-Cache-Tags added
Actions #2

Updated by Andreas Kienast about 1 month ago

  • Status changed from New to Closed

Thank you for reporting this issue.
This is ticket is a duplicate of #105703, therefore I'll close it. Let's work in the original ticket.

Actions

Also available in: Atom PDF