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

Does not clear cache...

 
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
CrazyTemplate
Smarty Rookie


Joined: 12 Sep 2011
Posts: 31

PostPosted: Wed Jul 09, 2014 10:40 am    Post subject: Does not clear cache... Reply with quote

I create various products and cache them with:

smarty->isCached("product.html", "product|".$product->id)

But when I try to clear their cache, it doesn't clear anything:

$smarty->clearCache("product.html", "product|".$product->id);

All files are still there, page is still showing the old content. The only way that I've found to clear the cache, is to delete the cache files myself.

Is this a bug or am I doing something terribly wrong?

Thank you.
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Wed Jul 09, 2014 3:29 pm    Post subject: Reply with quote

isCached() does check if a valid cache file does exists or not. It does not create a cache file.

Cache files are created and later called for display with the display() or fetch() calls. They are created with the cache_id specified in display() or fetch(). Did you do that?
Back to top
View user's profile Send private message
CrazyTemplate
Smarty Rookie


Joined: 12 Sep 2011
Posts: 31

PostPosted: Wed Jul 09, 2014 4:55 pm    Post subject: Reply with quote

I copy/pasted only the first part. My overal logic is like this:

- check isCached()
- if false then load data from database to fill html parts
- else if true then continue
- call display() to show html template

My display() command looks like:

$smarty->display('product.html', "product|".$product->id);

I still don't understand why clearing the cache does not work.

I checked the cache files, they are correctly named like "product^1234^xyxrandomchars.product.html.php"
Back to top
View user's profile Send private message Visit poster's website
CrazyTemplate
Smarty Rookie


Joined: 12 Sep 2011
Posts: 31

PostPosted: Wed Jul 09, 2014 5:17 pm    Post subject: Reply with quote

Could it be that I load Smarty from different directory locations?

the site runs like: domain.com/product.php
which loads Smarty with:
$smarty = new Smarty();
$smarty->setTemplateDir(array('./templates', './templatesextra'));

but the admin interface that runs the clearCache() is like: domain.com/cms/cache-control.php
which loads Smarty with:
$smarty = new Smarty();
$smarty->setTemplateDir(array('../templates', '../templatesextra'));

but I don't receive any errors...
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Wed Jul 09, 2014 10:21 pm    Post subject: Reply with quote

That's the problem. Smarty does encode folder information into the file name that it can handle templates with same name but from different folders. Now in your case the folder names are not identical. It should work if you use absolute path.

like realpath('./templates') and realpath('../templates')
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