Re[2]: [SMARTY] Caching newbie questions
| From: | Jacques Jocelyn | Date: | Sat, 05 Apr 2003 17:00:40 +0000 |
| Subject: | Re[2]: [SMARTY] Caching newbie questions | ||
| References: | 1 2 3 4 5 6 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9123@lists.php.net to get a copy of this message | ||
Hello messju,
>> > The performance decreased immensely !
>> > Without replacing the SID, I could generate the page in .30s
>> > By Replacing the SID, Now it is about .70s
>> > so if I have several templates to display, that might be a big issue.
>>
>> 400ms are a long time.
>>
>> if you can use str_replace instead of preg_replace it is much faster.
>> also: output-buffering slows down the thing a lot. maybe it is faster
>> if you do
>>
>> ob_start('replace_func')
>> $smarty->display
>> ....
mm> correction: using a callback-function does not seem to speed up
mm> anything. it seems to do the opposite :(
hey guys, just to give you an update, this SID replacement was killing
me :-/
I use this extension and it is working JUST FINE !
class MySmarty extends Smarty{
function display($tpl_file, $cache_id = null, $compile_id = null)
{
// Get the current session ID for replacing the old current SID
$SID = session_id();
$pattern = "^/SID/[[:alnum:]]{32}^";
$replacement="/SID/".$SID;
$output = $this->fetch ($tpl_file, $cache_id, $compile_id);
$output=preg_replace ($pattern,$replacement, $output);
echo $output;
}
}
Without this extension the page was generated between .31s to .34 s
With the extension (AND by replacing the sid)
Now it's between : .32s to .34 !
for the history, before I was using the following :
$output = $this->fetch ($tpl_file, $cache_id, $compile_id);
$this->fetch($tpl_file, $cache_id, $compile_id, true);
echo ereg_replace("/SID/[a-zA-Z0-9]{32}","/SID/$SID",$output);
Thanks all for your guidance
Best regards,
Jacques JOCELYN