Search code examples
http-redirectcachingtypo3realurlpibase

Issue with realurl, redirect and caching in TYPO3


This error occures in TYPO3 7.6.10 with a piBase extension and realurl 2.0.15:

In this extension, I'm checking for a GET parameter, e.g. a country. If this parameter is not provided, I redirect to the same page, with default country as parameter:

if(!$this->piVars['country']) {
  $this->piVars['country'] = 'germany';
  \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->pi_linkTP_keepPIvars_url(array(), true), \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
}

That means, the visitor e.g. calls url www.mypage.com/list/ and is redirected to www.mypage.com/list/germany/

This works fine, but after some time passes and some visitors were an the page, the redirect stopped working. When opening www.mypage.com/list/ in the browser, the page is displayed for some country (not the default one, e.g. for country "france"). That means, TYPO3 creates on page www.mypage.com/list/france/ a cache entry for page www.mypage.com/list/, but for this url, a cache entry should've never been created, because of the redirect.

I can reproduce this error by setting caching time of the page to 1 minute. Then I wait one minute, then loading the url www.mypage.com/list/france/. Now, when opening www.mypage.com/list/, there is no redirect and france is shown.

When disabling realurl (or just removing parameter "country" from realurl configuration), this error doesn't occur.


Solution

  • The problem is described here: realurl generates entries without cHash

    Since version 2.0.15, realurl doesn't calculate the cHash parameter for links, which are accessed directly and which need a cHash parameter to show the right cached contents, like detail pages of a record.