Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Caching with Smarty - A few best practice questions

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
simplex
Smarty n00b


Joined: 03 Apr 2021
Posts: 4

PostPosted: Sat Apr 03, 2021 8:51 pm    Post subject: Caching with Smarty - A few best practice questions Reply with quote

Hi,

I have played around with caching a bit, and I have to say that I was surprised how simple and painless it was. with just a few lines of additional code, the massive smarty frontend was cached, with just a few small issues, that can be easily solved by a few more lines of code

My question is this: Having a cached smarty frontend is nice, however, in my case, all the PHP code which is needed for the frontend, is still executed. So as you can imagine, load time savings were not really there. What are the best practices to only execute the PHP code that is needed for the uncached stuff?

All I can think off is using isCached() and depending on the result, decide which php code to execute.

Am I on the right path with this, or are there better ways?

Cheers
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Apr 04, 2021 4:53 pm    Post subject: Reply with quote

That's basically the only way to do it.
Carefully inspect your code, group stuff that only calculate template variables, and wrap it into if(!isCached()) block.
Back to top
View user's profile Send private message
simplex
Smarty n00b


Joined: 03 Apr 2021
Posts: 4

PostPosted: Mon Apr 05, 2021 2:03 pm    Post subject: Reply with quote

AnrDaemon wrote:
That's basically the only way to do it.
Carefully inspect your code, group stuff that only calculate template variables, and wrap it into if(!isCached()) block.


Thanks for the info.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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