[Typo3-dev] useCacheHash in FE-plugins, typolink, pi_base
Ernesto Baschny [cron IT]
ernst at cron-it.de
Wed Oct 5 19:37:29 CEST 2005
Elmar Hinz schrieb am 05.10.2005 18:56:
> (...)
> Both articels don't touch the question how the cHash is
> initiated/created at all. This led me to the assumption that the cHash
> is created automatically by typolink function if it is used inside a
> USER plugin.
That is correct.
> What speaks against this assumption is the presence of a useCacheHash
> property in TSref for the typolink function.
Not really. Your plugin has to decide if a link is "cacheable" or not
and set useCacheHash appropriately for links that are worthwhile to be
cached.
> TYPOLINK
>
> 1.) Is cHash created automatically inside USER objects by the typolink
> function or do you have to build or configure them?
It's created automatically if you call the typolink function with the
"useCacheHash" property set. Normally in plugins you will create links
using the pi_linkTP*() family of functions. These will set the
useCacheHash automatically for you if you set the $cache parameter to
"1" (ok, if you have $this->pi_USER_INT_obj = true in your plugin, this
will override the $cache parameter).
To decide which link to $cache and which not, you have to think if the
combination of parameters that the user is submitting is something
worthwhile to cache or not. Only make cacheable links if you have a
countable amount of parameter/value combinations.
See tt_news as an example. Its an USER object, and thus cacheable, if
the user set the "allowCaching" config. All links go through pi_linkTP*
and if allowCaching was true, these will get an cHash calculated and
appended (tt_news-developer doesn't have to do anything for this to
happen). The link-destination will then see the cHash, the parameters,
and see they match, thus it was a link created by TYPO3, and thus, will
cache the resulting output. This way noone can "pollute" typo3 cache
just by requesting the same page with different parameters.
> 2.) How do you build links that match the concept of cHash and USER
> plugins?
See tt_news, for an up-to-date example.
> PI_BASE
>
> 3.a) Do the pi_base link functions work with the concept of cHash at all?
See above. Yes, they all call typolink internally, so it works the same way.
> 3.b) Do they set it automatically or do you have to configure it for
> pi_base link functions?
Just set the $cache parameter and make sure you have not set
$this->pi_USER_INT_obj to TRUE in your plugin.
> 3.c) If you have to configure it how do you do it correctly?
Not needed!
Cheers,
Ernesto
More information about the TYPO3-dev
mailing list