|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 41
|
Posted: Sat Apr 14, 2012 4:31 am Post subject: Whats the fastest way to load the templates |
|
|
I am in the process of upgrading from smarty 2 to 3 and thought I would see what the fastest way to load the templates.
We are currently passing objects to the template and calling the object functions instead of assigning each variable. We are doing this because the pages are very dynamic. All of the templates are stored in a database to make it easier to monitor new versions of the page along with being able to go back to an older version very quickly. We can switch the way we keep track of the templates and store them on the server HDD, but which would actually load faster? The site is still storing the compiled cache php page from a folder, but it does query the DB a couple times per each template that is loaded. So if a template loads in a header template, sidebar template and footer template (4 templates) that means it runs 8 querys on the DB (on another server). It seems like it would be better if it read the timestamp from the template file to see when the last time it was created instead of querying the DB but just wanting to get other opinions.
I also thought I read somewhere that you can use memcache with smarty. Is this another way to increase the performance of a high traffic site? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Apr 14, 2012 4:14 pm Post subject: |
|
|
Smarty 3 can combine compiled templates and make template loading very fast, less disk IO. I wouldn't bother moving things out of the db into files for the purpose of speed. Caching will save db calls. If you have caching enabled, you can use memcached to store the cache for a memory based cache fetch. I think you can do that in Smarty 2 as well. |
|
Back to top |
|
redbrad0 Smarty Regular
Joined: 03 Feb 2007 Posts: 41
|
Posted: Sat Apr 14, 2012 4:31 pm Post subject: |
|
|
I will leave the templates in the DB then.
Our server does have memcache running, which I will look into enabling for smarty but this brings up the last question about caching. If I turn on smarty caching and memcache for smarty, it will only cache the template and not the data correct? When a new order is placed or a product is sold out it has to display it right away. If it is only caching the template code but reads the new variables assigned to it then I will be good to go, but just wanted to double check. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Apr 14, 2012 6:33 pm Post subject: |
|
|
caching stores the output of fetch() or display(). if you need dynamic vars, you can mark variables as not cached, but it may be better to just leave caching off. of course compiled templates do not recompile between page loads if templates do not change. |
|
Back to top |
|
|
|
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
|