|
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 |
AnteD Smarty Regular
Joined: 14 Dec 2004 Posts: 38
|
Posted: Mon Sep 03, 2007 5:22 pm Post subject: templates_c full |
|
|
Hi there...
Been using Smarty in my everday work for years...best tool around
3 days ago I started working on a web site re-using smarty dir from previuos projects...when I wanted to upload my site I notice that the templates_c dir was 50MB! Here's my Temlates class which extends Smarty..is there any other setting I didn't set here that could be causing this...
Code: |
class Template extends Smarty {
/**
* Constructor...
*
* @return void
*/
public function __construct() {
parent::Smarty();
$this->caching = false;
$this->template_dir = SMARTY_TEMPLATE_DIR;
$this->compile_dir = SMARTY_DIR ."templates_c";
$this->compile_id = md5(time());
}
} |
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Sep 03, 2007 6:02 pm Post subject: |
|
|
Your problem is
Code: | $this->compile_id = md5(time());
|
This creates every second a different compile id and because of that the templates are getting recompiled and stored with a different compile id over and over again.
Why did you use compile id's at all? |
|
Back to top |
|
AnteD Smarty Regular
Joined: 14 Dec 2004 Posts: 38
|
Posted: Mon Sep 03, 2007 8:23 pm Post subject: |
|
|
because I have a smarty dir that is being used by 100 of web pages on my production server and sometimes I would get "ghost" pages displayed (from another page) while browsing some page..so I got an advice to use something really changeable (more unique)..before that I was using md5(BASEURL) where BASEURL = "http//www.mydomain.com" so I changed it to md5(time()) |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Sep 03, 2007 9:09 pm Post subject: |
|
|
Hmm. Compile_id's make only sense if you have different templates with the same name. Each template version should have it's own compile_id to distiguish the compiled templates in the template_c directory. So for example md5(BASEURL) should be sufficent if the template name is unique within the domain. If this is not the case and you have within a single domain templates with same name in some subdirectories you must choose different unique compile_id's. However the compile_id's should not change over time. Otherwise it will fill up your template_c directory and you will have bad performance.
So did the "ghost" pages display content from a different domain or just wrong content of the same domain? |
|
Back to top |
|
AnteD Smarty Regular
Joined: 14 Dec 2004 Posts: 38
|
Posted: Tue Sep 04, 2007 7:19 am Post subject: |
|
|
This is exactly what happened...as I said smarty templetes_c dir is used by 100 of web pages which are built on the same CMS (mine) so it is very common for the templates to have same name (ie catalog.add.tpl) so I was getting "ghost" templates from other projects sometimes shown (but scrambled) in some other project..you would then refresh and everything was ok...
check this thread... http://www.phpinsider.com/smarty-forum/viewtopic.php?t=10192&highlight=
My guess is that I made it a bit too unique.....as time() is really unique for every second....
UPDATE: man I was so affraid to look into smarty templates_c dir now on my production server..I was expecting 500Mb of files as from the time I read the thread I've sent you url for I was using md5(time()) as a compile_id but I was saved with the previous implementations where I was using clear_compile_dir() so the "old" projects were cleaning the compile dir for me as the new ones were all using md5-ed time...huh...
But I still don't know what would be the most optimal solution..ok md5(BASEURL) it not good....on the other hand md5(time()) is too unique....
confused |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Sep 04, 2007 12:36 pm Post subject: |
|
|
md5(BASEURL) should be sufficient if you don't have more than one template_dir per BASEURL. |
|
Back to top |
|
AnteD Smarty Regular
Joined: 14 Dec 2004 Posts: 38
|
Posted: Tue Sep 04, 2007 3:20 pm Post subject: |
|
|
nope..I don't...thanx guys... |
|
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
|