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

Most ideal template resource (file, database...)

 
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 -> Tips and Tricks
View previous topic :: View next topic  

Template resource that we use
File
100%
 100%  [ 8 ]
Database
0%
 0%  [ 0 ]
Total Votes : 8

Author Message
powerobject
Smarty Rookie


Joined: 14 Jan 2006
Posts: 18

PostPosted: Sat Jan 14, 2006 4:19 am    Post subject: Most ideal template resource (file, database...) Reply with quote

On a high-traffic website that does a db connection for every page anyway, which approach is more efficient:

1. Store templates in a database and retrieve from it (db connection already exists)

2. Load templates from the file-system (fopen, fread, fclose...)

thanks
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Sat Jan 14, 2006 4:36 pm    Post subject: Reply with quote

When using caching, it doesnt matter.
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Jan 14, 2006 6:46 pm    Post subject: Reply with quote

when turning off $smarty->compile_check it doesn't matter, either.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
loginx
Smarty n00b


Joined: 20 Jan 2006
Posts: 2

PostPosted: Fri Jan 20, 2006 4:03 pm    Post subject: Reply with quote

One big issue you will encounter while storing template files in the DB is that the design team will have a really hard time making design changes to the application. This may not matter to you today if you are the only one working on a certain app, but if you ever need for whatever reason to involve a real designer in this sort of project, they will go insane.

I always found that designers are never too happy about working with templates in general, let alone if they need to connect to a DB to get to those files and re-upload them.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Jan 21, 2006 12:20 am    Post subject: Reply with quote

loginx wrote:
One big issue you will encounter while storing template files in the DB is that the design team will have a really hard time making design changes to the application. This may not matter to you today if you are the only one working on a certain app, but if you ever need for whatever reason to involve a real designer in this sort of project, they will go insane.

I always found that designers are never too happy about working with templates in general, let alone if they need to connect to a DB to get to those files and re-upload them.


You can write a simple tool to synchronize files on an as-needed-basis. I think a lot of people naturally use the same platform for deployment and development, but depending on your workflow, this need not be the case -- and they need not be identical in terms of how services are physically deployed.
Back to top
View user's profile Send private message
mrLenin
Smarty n00b


Joined: 24 Nov 2006
Posts: 4

PostPosted: Thu Jan 18, 2007 1:43 pm    Post subject: Reply with quote

Both ways are almost the same on a high-traffic website.
_________________
Article Directory
Article Robot
Back to top
View user's profile Send private message
JasonDS
Smarty Rookie


Joined: 25 Jan 2007
Posts: 25

PostPosted: Thu Jan 25, 2007 6:00 am    Post subject: Reply with quote

I would say it's bad practice to store files in a database..

I am very stereo-typical about things like that.. I like to balance the load of objects and keep un-necessary content out of my code.

When designing something that affects every page load, you have to consider how it affects you, performance, and the server.

On your end, it's a great deal of folders and files being tossed away.

On the server's end, it means high traffic and a ton of looping. This of course affecting the average load time, as for every page-load there is a new query to get the file.

If you're looking for an easier method of loading the files, design a few functions that suite your needs and use them.

But I believe that the last files such as these belong, are in the database.

Smile
Back to top
View user's profile Send private message Send e-mail
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Jan 25, 2007 8:06 am    Post subject: Reply with quote

Not really.

What the previous posters where getting at is that unless you've modified Smarty heavily to do otherwise, all template resources -- no matter where they originate from -- are compiled into a PHP file. Furthermore, this compilation only happens when the file is compiled; from then on, the compiled PHP file is used. Typically compilation occurs infrequently. The upshot is that, on average, you still get file system performance. If you are then using a opcode cache (like APC, eAccelerator, what-have-you) then those compiled files will exist there, just like any other PHP file.

The point is that Smarty's compiling means that any type of resource (template or config file) from any general source will on average have a similar performance profile to a strictly file based one.
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 -> Tips and Tricks 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