Yesterday I encountered yet another unusual TYPO3 problem. An external web site had to link to pages on a TYPO3 site providing various parameters for an extension on one page. The extension is cacheable because it does certain network queries and it will be slow to do them for each request. So extension uses cHash for proper caching.
The problem was that the external site could not create cHash. cHash creation is not trivial and involves using site–specific encryption key. So the external site could not ptovide cHash and displayed content was wrong: it was like the page was called without any parameter.
What could I do?
There were several choices:
- make external site send proper cHash. Difficult and not secure to let others know the encryption key
- make plugin non–cached. Bad because affects performance
- make plugin cacheable in general but non–cached only if cHash is missing
I decided on the last choice. Plugin will be cacheable only if cHash exists in the URL. But how do I do it? When plugin is cached, it is not called. So there is no way to check cHash for each request from the plugin.
Fortunately my experience with TYPO3 gave me the answer in 30 seconds. I will use conditions. Here is how it looks like:
plugin.tx_myext_pi1 = USER
[globalVar = GP:cHash = ]
plugin.tx_myext_pi1 = USER_INT
[global]
So when user clicks normal links, cHash is present and plugin is cached. When request comes from the external server, plugin is not cached because cHash is missing.
Why did I use this approach and not this:
plugin.tx_myext_pi1 = USER
[globalVar = GP:cHash = ]
config.no_cache = 1
[global]
The answer is simple. The page contains also many other elements. They still could be cached. This improves performance. no_cache is always bad. So I do not use it and do not recommend anyone to use it. Always try to find the other way. It usually exists.
A warning
While the above TypoScript works, do not use it unless you really need it. Do it only if you understand why you have to use it and what implication you have if you use this code. I published this code only to show that there are different solution to the problem and the first obvious solution (no_cache) is not good.
Use TYPO3 smartly!

In some cases it does not work as expected.
For example tt_news can replace page title with news title when called as USER. But when called as USER_INT it does not!
What's strange ist, that TYPO3 makes a 'wront chash error' which is not displaied if you don't enable the option in localconf.php for that. So basically it makes a no_cache out of the page.
How did you handle that? Does TYPO3 recognize the USER_INT and does not make a no_cache even if the cHash is wrong or empty?
(By the way, your book is great! Sonja already read it and she realy likes it)
Does cHash work clean if I set pi_checkCHash to 0? So if I have different cHash it also does different caches?
What's about Forms, so if I have a form with parameters which do not have a cHash and I don't use pi_checkCHash -> does it cache or not?
Just to make shure I got it righti, because it's not that clearly documented (I know kaspars doc by heart...).
Best regards,
Jonas
For forms you should always have non–cached plugin or a condition (as above).
What about the case when your plugin doesn't get any cHash or any parameter.
Like the default case, when your plugin is inserted with some flexform options, in this case it should be cashed.