|
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 |
seven[hr] Smarty n00b
Joined: 04 Nov 2004 Posts: 3
|
Posted: Sat Jul 15, 2006 12:28 pm Post subject: is_cached caching compile_id display fetch |
|
|
I am working on a rather complex site, and I need all caching I can get (templates, database, arrays…). I have master index.html template which fetched some stuff, and I have {$content} tag inside the index template in which my php application logic fetches other templates and assign lots of stuff to those fetched templates.
First I built non cached non optimized version, then slowly changed things one by one and benchmarked every change. Smarty templates caching came last on the list and at first sight everything worked fine.
Code: |
$template_cache_id = md5($_SERVER['QUERY_STRING']);
…
if( !$smarty->is_cached('index.html', $template_cache_id)) {
.. lots of stuff
}
$smarty->display("index.html", $template_cache_id);
|
I had some issues with my session management, and clearing the all around cache after modifications to database has been made, but I managed to solve that and I went to sleep. The next day things went completely mad. I was getting wrong content on all complex pages (built with few fetches and assigned to {$content}).
The thing is… I forgot to pass $cache_id to fetch().
Code: | $output_sidebar = $smarty->fetch('sidebar_recent_news_events.html', $template_cache_id); |
Just wanted to post this so when I forget what I did few months from now I can eventually find this post.
Before caching my page executed in approximate 0.175 sec, but after optimization execution was around 0.092 sec. (now I have to do some more serious benchmarking not based on page execution)
Best regards
N. |
|
Back to top |
|
pnoeric Smarty Rookie
Joined: 03 Mar 2006 Posts: 29
|
Posted: Tue Jul 29, 2008 6:28 am Post subject: thanks! |
|
|
totally the problem I was struggling with-- thanks for posting it here in the forums! just found it and my caching is working great now... yay... |
|
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
|