[TYPO3-english] Caching multiple versions of the same page with a unique URL
Jigal van Hemert
jigal.van.hemert at typo3.org
Thu Jul 21 22:30:33 CEST 2016
Hi,
On 21/07/2016 15:20, Fabrice Morin wrote:
> What is the best way to cache multiple versions of a page (using the
> cHash mechanism) when this page have a unique URL but can be dynamically
> changed using information in the request header ?
>
> The use-case is using Akamai content-targeting. Akamai sends the
> country_code in the request header, we can retrieve it from PHP, compute
> the page content according to this country code and render the page. The
> problem is to cache the result, since the URL is unique to all
> countries, the cHash will be identical for all visitors from different
> countries, and the first visitor will cache the page for everyone.
>
> Is there a way to alter the cHash computation ? According to what I see
> from TypoScriptFrontendController::makeCacheHash() function, only the
> query string is relevant, and there is no hook.
In
\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::createHashBase()
you can see that the "template" (= TypoScript) is also included in hash
calculation. With conditions in TS (for example a custom condition that
looks at the request header) it should be possible to have different
versions of the page for each country_code.
If that fails horribly then there is always a hook in createHashBase()
you can use to influence the hash calculation.
--
Jigal van Hemert
TYPO3 CMS Active Contributor
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-english
mailing list