View previous topic :: View next topic |
Template resource that we use |
File |
|
100% |
[ 8 ] |
Database |
|
0% |
[ 0 ] |
|
Total Votes : 8 |
|
Author |
Message |
powerobject Smarty Rookie
Joined: 14 Jan 2006 Posts: 18
|
Posted: Sat Jan 14, 2006 4:19 am Post subject: Most ideal template resource (file, database...) |
|
|
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 |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Sat Jan 14, 2006 4:36 pm Post subject: |
|
|
When using caching, it doesnt matter. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Jan 14, 2006 6:46 pm Post subject: |
|
|
when turning off $smarty->compile_check it doesn't matter, either. |
|
Back to top |
|
loginx Smarty n00b
Joined: 20 Jan 2006 Posts: 2
|
Posted: Fri Jan 20, 2006 4:03 pm Post subject: |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Jan 21, 2006 12:20 am Post subject: |
|
|
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 |
|
mrLenin Smarty n00b
Joined: 24 Nov 2006 Posts: 4
|
Posted: Thu Jan 18, 2007 1:43 pm Post subject: |
|
|
Both ways are almost the same on a high-traffic website. _________________ Article Directory
Article Robot |
|
Back to top |
|
JasonDS Smarty Rookie
Joined: 25 Jan 2007 Posts: 25
|
Posted: Thu Jan 25, 2007 6:00 am Post subject: |
|
|
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.
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Jan 25, 2007 8:06 am Post subject: |
|
|
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 |
|
|