|
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 |
xso Smarty n00b
Joined: 19 Jul 2003 Posts: 1 Location: Frankfurt, Germany
|
Posted: Sat Jul 19, 2003 11:17 am Post subject: Problem with caching |
|
|
Hi,
It looks like I'm having a problem with caching in Smarty. I use ApacheBenchmark (1000 connections, 10 concurrent connections), in order to test the performance boost provided with caching pages.
With caching disabled, I have around 183.18 requests per second. With caching enabled, I have around 179.64 This leads me to thinking that Smarty is not taking results from the cache (although there are in the cache directory).
The code is quite simple:
Code: |
index.php
<?php
require_once 'phpsec.conf.php';
require_once COMMON_PATH . 'header.php';
$smarty->display(TPL_PATH . 'index.tpl');
require_once COMMON_PATH . 'footer.php';
?>
|
and the settings are:
Code: |
phpsec.conf.php
<?php
define ('COMMON_PATH', '/phpsec/www/common/');
define ('EXT_LIBRARY_PATH', '/phpsec/php/ext/');
define ('TPL_PATH', '/phpsec/php/tpl/');
require_once EXT_LIBRARY_PATH . 'smarty/Smarty.class.php';
$smarty = new Smarty;
$smarty->template_dir = '/phpsec/www/tpl/';
$smarty->compile_dir = '/phpsec/spool/templates_c/';
$smarty->cache_dir = '/phpsec/spool/cache/';
$smarty->caching = true;
?>
|
I'm sure it's something obvious but I just can't figure it right now... I read the manual, the FAQ and made a search in the forums, but no cigar.
Any help would be greatly appreciated.
Thanks.
Xavier |
|
Back to top |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Tue Aug 05, 2003 8:36 pm Post subject: |
|
|
Hi,
$caching is supposed to be any of
0 = no caching
1 = use class cache_lifetime value
2 = use cache_lifetime in cache file
but true/false should map to 0/1 usually.
Then you should explicitly set
$cache_lifetime = 3600;
$compile_check = true;
$force_compile = false;
although these are the default values.
I assume 'phpsec.conf.php' is in the same directoy as index.php. If you have a long include_path with a lot of files in it, PHP may waste time to search for it.
Then you have some other PHP files, "header.php" and "footer.php". If you want to benchmark Smarty, keep them outside. If they request a db to feed Smarty, it'll always need to recompile the templates, so you may simply need to "optimize" your templates. A single index.tpl that constantly receives new data upon each request is not worth caching. Have the parts that are dynamic in their own templates and {include} them. split them up and use is_cached()
Have fun,
CirTap |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Aug 05, 2003 9:32 pm Post subject: |
|
|
I somehow missed this post--perhaps I was on holiday. CirTap, another nice and helpful explanation. Still, I wonder if the problem lies in how the timing is being done. I'd be interested to see where and how xso (hi xso) made his timing measurements. |
|
Back to top |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Wed Aug 06, 2003 9:35 pm Post subject: |
|
|
boots wrote: | CirTap, another nice and helpful explanation. |
thank you , so actually someone is reading my stuff *lol* |
|
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
|