Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
caching to false and include + cache_lifetime

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
adn
Smarty Regular


Joined: 31 May 2011
Posts: 47

PostPosted: Thu Mar 29, 2012 1:47 pm    Post subject: caching to false and include + cache_lifetime Reply with quote

Hello,

I have replaced some "include + inline" by "include + cache_lifetime" and I am surprised when using caching mode to false that my template are not refreshed. If I go back with this modification the refresh is done.

Is that a normal behavior? I thought that even if I put a cache_lifetime attribute the include should be refreshed.

What's wrong?
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4200
Location: Hamburg / Germany

PostPosted: Thu Mar 29, 2012 4:29 pm    Post subject: Reply with quote

If you use the cache_lifetime attribute with the {include} tag that subtemplate gets cached with it's individual lifetime independent from any global cache setting of the Smarty object.

So with $smarty->caching = false; the content of the main template is not cached but the content {include ... cache_lifetime = ...} subtemplate is.

To disable caching of single subtemplates when caching is globally on use {include .... nocache}
Back to top
View user's profile Send private message
adn
Smarty Regular


Joined: 31 May 2011
Posts: 47

PostPosted: Thu Mar 29, 2012 5:10 pm    Post subject: Reply with quote

Is there a way to say "nocache" for the template and all subtemplate? I have a debugging mode where I put $smarty->caching = false; to test an enhancement or to do some test. It is quite difficult to modify all the includes in template for that.
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4200
Location: Hamburg / Germany

PostPosted: Thu Mar 29, 2012 7:27 pm    Post subject: Reply with quote

Note that you must use {include ... cache_lifetime = ...} only for subtemplates which shall have a lifetime different from the main or calling template.

If you want to cache the whole page with no different lifetime for the subtemplates use a simple {include} otherwise you loose performance.

You can't disable caching of subtemplates which have {include ... cache_lifetime = ...}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP