Apr 28, 2009

When do you need cHash in TYPO3

cHash is one of the most mysterious and misunderstood parameters in TYPO3. There are several articles about cHash on the web (including my own, see below) but it still remains a mystery.

cHash is important for proper caching in TYPO3. Therefore I decided to write when you need it and when not.

When to use cHash

You need cHash when:

  • the content of the page depends on the parameter of the URL, and
  • you do not use conditions, and
  • you want the content to be cached

This typically happens in extensions. The extension must produce links with cHash if its output depends on the URL and the extension is of USER type.

When not to use cHash

You do not need cHash if:

  • you create a USER_INT (non–cached) extension
  • you generate different output using TypoScript conditions on the URL parameter
  • you limit pages or site content to various user groups

In other words, care about cHash if you write PHP code. Forget cHash for the rest of TYPO3.

5 comments:

  1. Dmitry, you also explain the cHash in your extension development book. But I could be totally wrong, but if we look at tt_news, without RealURL the cHash parameter is there. With RealURl, the cHash parameter is gone (could be our configuration of course). Could that be a potential problem?

    ReplyDelete
  2. IMO you don't need it if the only parameter you append is L



    @Mark: this is no problem: if every parameter is rewritten by realURL, you don't need it

    ReplyDelete
  3. @Georg: Right because the &L parameter is usually handled by a TypoScript condition.

    ReplyDelete
  4. On every project i set up I install realurl and nc_staticfilecache, and i rewrite all parameters with realurl.

    nc_staticfilecache creates a static file for every possible parameter, so cHash is not needed right?

    ReplyDelete
  5. If you use RealURL _and_ there is not "?" and unresolved parameters after it, than RealURL will handle cHash internally.



    For example:

    http://localhost/news/?tx_ttnews[tt_news]=123&cHash=12345678

    http://localhost/news/t3dd09-are-coming/



    Both may refer to the same news item but for the second RealURL takes care.

    ReplyDelete