[TYPO3-dev] Strange page cache behaviour

Markus Opahle markus at opahle.com
Wed Jul 1 14:01:08 CEST 2015


Hi everybody,

I have a website with two domains and where both domains have the same
rootpage. The contents on both domains are slightly different and are
mainly distinguished by typoscript condition (like [globalString =
IENV:HTTP_HOST = *.domain1.com]).

- When I now call a cachable page from domain1 (domain1.com/foo) the page
will be cached.
- When I call the same page from domain2 (domain2.com/foo) the page will
not be cached.
- When I clear the page cache and call domain2.com/foo first, it will be
cached but then domain1.com/foo will never be cached.

After a little debugging I discovered that TSFE sometimes uses different
identifiers for getting and setting page cache values:
1. TSFE->getFromCache() uses hash1
2. TSFE->generatePage_preProcessing() generates hash2
3. TSFE->setPageCacheContent uses hash2
4. next request. TSFE->getFromCache() uses hash1 again and will never find
a cache entry

In most cases hash1 and hash2 are the same, but not in my case:
I use the following typoscript:
Constants:
[globalString = IENV:HTTP_HOST = *.domain1.com]
myconstant = my.ip
[global]

Setup:
[IP = {$myconstant}]
...
[global]

This leads to different values in TSFE->all and therefore to different
cache identifiers per domain. However  TSFE->getFromCache() uses a cached
value for TSFE->all (from pagesectioncache) and this cache only depends on
the page id and the Mountpoint.
So what happens is this:
1. When the cache is empty we call domain1.com/foo
2. TSFE generates TSFE->all for domain1.com and caches it under the uid of
page "foo"
3. TSFE generates a cache entry with an identifier based on the current
TSFE->all (and other values)
4. now we call  domain2.com/foo
5. TSEE->getFromCache() reads the TSFE->all value from cache (which was
generated in step 2) , evaluates the conditions defined in TSFE->all['all']
and stores them in TSFE->all['matches']
6. TSEE->getFromCache() now tries to fetch a cache entry with an identifier
based on the current TSFE->all value (which fails)
7. TSFE->generatePage_preProcessing() generates a new hash which is
different because one condition in TSFE->all['all'] changes (the one from
above under "Setup").
8. TSFE generates a cache entry with an identifier based on the current
TSFE->all (and other values)
9.  now we call  domain2.com/foo again and continue with step 5. We will
never hit the cache.

So is this a bug or am I missing something?



More information about the TYPO3-dev mailing list