Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

problems with is_cached function

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
schildi
Smarty Regular


Joined: 11 Mar 2005
Posts: 81

PostPosted: Tue Nov 06, 2007 9:39 am    Post subject: problems with is_cached function Reply with quote

hi,

i dont know why i do not get a 'true' from the smarty->is_cached function:

//smarty->caching is set to 1
$smarty->caching = 1;
if($smarty->is_cached("pg.tpl_index.tpl", "9a07502522ddaf254885c72af8cbd645")) echo("site cached!");
else echo("site not cached!");

//result is "site not cached!" Sad

cache content is:

9a07502522ddaf254885c72af8cbd645^%%82^826^82667930%%pg.tpl_index.tpl

why isnt the result true? dont know what do do.. - can anyone help?
Back to top
View user's profile Send private message Send e-mail
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Tue Nov 06, 2007 10:28 am    Post subject: Reply with quote

I'm pretty sure, you never call
Code:
$smarty->display('pg.tp_index.tpl', "9a07502522ddaf254885c72af8cbd645");

Therefore Smarty is right and this site with this cache_id isn't cached.

Take a closer look at
http://smarty.php.net/manual/en/api.is.cached.php
to see how is_cached really works.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
schildi
Smarty Regular


Joined: 11 Mar 2005
Posts: 81

PostPosted: Tue Nov 06, 2007 10:40 am    Post subject: Reply with quote

i do call

$smarty->fetch($smarty->template_dir."pg.tpl_index.tpl", "065e13a4ad77e322079da9bcc8f26dfa");

and i thought i dont need to declare $smarty->template_dir when using is_cached function

thanks!!
Back to top
View user's profile Send private message Send e-mail
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Tue Nov 06, 2007 2:19 pm    Post subject: Reply with quote

IMO this should be sufficient
$smarty->fetch('pg.tpl_index.tpl', $cache_id);

Smarty looks for the template in $smarty->template_dir anyway.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 06, 2007 7:09 pm    Post subject: Reply with quote

AFAIK, the cacher (actually, the filename hasher, I suppose) will treat "pg.tpl_index.tpl" differently than "/some/path/pg.tpl_index.tpl". Thus, Celeb's comments do apply here.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Nov 06, 2007 7:53 pm    Post subject: Reply with quote

Also you must use the same cache_id for the fetch and is_cached call. In your example you have used different strings.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP