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

Cache This Phrase Globally?

James

Well-known member
#1
When would you choose not to cache a phrase globally? I'm not understanding why you wouldn't want to cache it...
 

James

Well-known member
#3
So if I was creating the phrase to use in code, would I need to cache it?
Example:
phrase: something_else
code:
new XenForo_Phrase('something_else')

or does it only need caching if I'm using xen:phrase?
 
R

ragtek

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

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

Dr.Yontem

Formerly Tilkißey
#6
yes.

If it's in a php file, you "should" cache it(if not, it will work, but you'll have a additional query).
an example from controllerpublic_conversation file
819-822
PHP:
if (!$conversation)
{
throw $this->responseException($this->responseError(new XenForo_Phrase('requested_conversation_not_found'), 404));
}
requested_conversation_not_found phrase
admin.php?phrases/requested_conversation_not_found.9874/edit&language_id=0

xf_phrase table
9874 0 requested_conversation_not_found The requested conversation could not be found. 0 XenForo 0
it isnt cached phrase :S

and this phrase isnt using in ANY template

i am confused :S
 

Mike

XenForo developer
Staff member
#10
If it's in a php file, you "should" cache it(if not, it will work, but you'll have a additional query).
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).
 

Dr.Yontem

Formerly Tilkißey
#11
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).
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
 

James

Well-known member
#12
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.