1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Caching Phrases

Discussion in 'XenForo Development Discussions' started by ragtek, Nov 6, 2010.

  1. ragtek

    ragtek Guest

    ATM I'm creating cached phrases for the navbar and all other are uncached.
    When should we use cached phrases and when not?
  2. Lawrence

    Lawrence Well-Known Member

    I cache phrases I think are going to be used frequently (front end). For those in the ACP, I don't cache as they won't be used that often.
  3. Kier

    Kier XenForo Developer Staff Member

    You only need to cache phrases that are not referenced directly in templates.

    So, this phrase:

    <p>{xen:phrase my_phrase}</p>

    ... does not need to be cached, while the one referenced here:

    <p>{xen:phrase $phraseName}</p>

    ... needs to be cached or it won't work.

    It's not really a matter of caching for performance, it's a matter of caching so that the phrase is available at all. If the phrase content can be known at the point at which you save the template, it likely does not need to be cached.
    Darkimmortal, Jeremy and Shadab like this.
  4. Mike

    Mike XenForo Developer Staff Member

    For reference, that's not allowed - in this situation, the phrase would be prepared in the code via a new XenForo_Phrase object.
    Shadab and Jeremy like this.
  5. Lawrence

    Lawrence Well-Known Member

    Good information on when to cache phrases, thanks, guys! :)
  6. ragtek

    ragtek Guest

    that's why we need a developer documentation
  7. Jeremy

    Jeremy Well-Known Member

    This literally just made my day. :)
  8. Kier

    Kier XenForo Developer Staff Member

    Oops my bad.
    Dan likes this.

Share This Page