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

Cache This Phrase Globally?

Discussion in 'XenForo Development Discussions' started by James, May 31, 2011.

  1. James

    James Well-Known Member

    When would you choose not to cache a phrase globally? I'm not understanding why you wouldn't want to cache it...
  2. ragtek

    ragtek Guest

  3. James

    James Well-Known Member

    So if I was creating the phrase to use in code, would I need to cache it?
    phrase: something_else
    new XenForo_Phrase('something_else')

    or does it only need caching if I'm using xen:phrase?
  4. ragtek

    ragtek Guest


    If it's in a php file, you "should" cache it(if not, it will work, but you'll have a additional query).
  5. James

    James Well-Known Member

    Many thanks ragtek :)
  6. Tilkißey

    Tilkißey Well-Known Member

    an example from controllerpublic_conversation file
    if (!$conversation)
    $this->responseException($this->responseError(new XenForo_Phrase('requested_conversation_not_found'), 404));
    requested_conversation_not_found phrase

    it isnt cached phrase :S

    and this phrase isnt using in ANY template

    i am confused :S
  7. ragtek

    ragtek Guest

  8. James

    James Well-Known Member

  9. Tilkißey

    Tilkißey Well-Known Member

  10. Mike

    Mike XenForo Developer Staff Member

    I wouldn't say that.

    A phrase only needs to be considered for global caching if it's used outside of a template (thus, via the code). However, only think about globally caching a phrase if it is commonly used. For example, we cache all the date-related elements as they're basically used on every page. We never cache any infrequently used phrases (like error messages).
  11. Tilkißey

    Tilkißey Well-Known Member

    so, if i write an add-on with XenForo_Phrase code, should i cache that phrase?
    or, should i cache my add-on's base phrases?

    for example;
    Tab Name
    Error Messages
    New Page's Phrases (like XenStaff add-on page)

    sorry for my English if it isnt clearly
  12. James

    James Well-Known Member

    I think Mike is saying if you're going to see it commonly (navtabs, etc) then cache them. If you're only going to see it infrequently (like errors) then don't.

Share This Page