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

Cache problems

 
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
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Wed Sep 03, 2003 9:45 am    Post subject: Cache problems Reply with quote

Before you lynch me, yes I'm a smarty newbie, and yes I've searched through these forums for an answer already, but the responses I'm finding are way over my head. I'm a very experienced HTML developer, but a beginning PHP user and an even more beginning smarty programmer. I am understanding the context of how Smarty works, and I'm able to get it to do the things I want it to do pretty well. My problem is, I'm making all kinds of changes to templates and .php files as I mess around with site layout and explore how the code will best suit my needs. Unfortunately, it seems like everytime I make a change it's cached somewhere and when I go to fix an error (maybe a path to an included file was wrong or something), I don't know if I've fixed it or not because the error is cached somewhere in some code!

My working-case scenario: I tried including a .css file in one of my templates before I found out about the {literal} tag and I was calling it up by the direct path to the physical .css location. After I found out about {literal}, I deleted the .css file and just wrote out the css in the template I'm using. This SHOULD work fine, except now I get errors saying "Stat failed for /www/scc.css (errno=2 - No such file or directory)" - and I'm not even calling the dumb thing anymore! Obviously this call is cached somewhere, but I don't know where I'm supposed to look or what I'm supposed to delete. I do have that "cache" directory, do I just delete everything in there? I don't want to break anything. In looking over some posts from the past, I see people talking about forcing compiling and running cron jobs on cache flushers and all sorts of stuff... I have no idea how I'm supposed to set that up. Smarty itself works great, but I don't get why it caches everything everytime - I'm doing really basic MySQL calls and dumping information into a template... can I just get rid of caching altogether?

I apologize for sounding crazy... I just spent 2 months trying to get Smarty installed on a server that wouldn't take it, and now that I've switched hosts to accomodate, I'm getting errors for stuff that shouldn't even exist anymore! Aaargh. </end of vent> Thank you in advance for your help.
Back to top
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Sep 03, 2003 1:54 pm    Post subject: Reply with quote

first of all: always distinguish between caching and compiling. caching is optional, compiling is mandatory.

in development i would set:
$smarty->compile_check = true;
$smarty->caching = false;

if that doesn't help, additionally set:
$smarty->force_compile = true;
(this may slow down the pages, but all changes are recompiled immediately, that's more important in development than maximum performance).

if everythings works so far and the templates look good i would set (still in development):
$smarty->compile_check = true;
$smarty->caching = true;
$smarty->force_compile = false;

then i test if my cache-handling works, if i really have different cache_ids for different content of the same template etc.


if this is all okay. the same stuff should work with maximum performance on a production environment with these settings:
$smarty->compile_check = false;
$smarty->caching = true;
$smarty->force_compile = false;


after any updates i run a script that calls:
$smarty->clear_compiled_tpl();
$smarty->clear_all_cache();

after that the templates are recompiled on demand and the pages are cached as soon as they are requested.


regarding the error you get: " Stat failed for /www/scc.css (errno=2..." ? are you running 2.6.0-RC1 ? this version had an error in the cache-file-handling that causes the bug above. this is not a severe thing and clearing the cache/-directory should fix it. if you don't need features that really need 2.6.0, you may downgrade to 2.5.0 . if you really need it you should upgrade to the cvs-version it has a few fixes to bugs in 2.6.0-RC1, is quite stable and will stay stable until 2.6.0 is final. if you don't use 2.6.0-RC1 ignore this paragraph Smile


HTH
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Fri Sep 05, 2003 3:08 am    Post subject: Reply with quote

Thanks for the info. I'm still a little uneasy about how things are going if the default settings don't allow smarty to work the way it's supposed to, but I have made a little progress.

To make a long story short, the only way I can get my files to work is if i put

$smarty->caching = false;

in each one. (A really easy example is, if I put {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"} it should show the current date and time. However, after pulling up the page one time, it either "compiles" it or "caches" it (whichever you prefer), and if you hit refresh on the browser it never changes. If I add $smarty->caching = false; then it updates everytime you hit refresh.

What I'm to understand is that every one of my smarty php files should have that no cache line in it, correct?
Back to top
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Sep 05, 2003 7:18 am    Post subject: Reply with quote

$smarty->caching=false is the default, no need to set it explicitly.

btw: i recommend to use a single php-file that includes smarty.class.php and sets it up. include() this at the top of all you php-files that use smarty. so you get a single place where you can configure smarty for the whole website.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Fri Sep 05, 2003 7:22 am    Post subject: Reply with quote

Hm. Thanks for the help, but... if it's the default, then how come it won't work without that line?
Back to top
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Sep 05, 2003 7:36 am    Post subject: Reply with quote

i don't know, it seems to be set somewhere in your scripts between
"$smarty = new Smarty;" and "$smarty->display();" or in your subclass of smarty if you use such a thing.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Häakon
Smarty Rookie


Joined: 19 Jul 2003
Posts: 18
Location: San Diego, California

PostPosted: Mon Sep 08, 2003 11:13 pm    Post subject: Reply with quote

I think I found part of the problem... in some "setup.php" I had created (perhaps on the instruction of some kind of tutorial or something) that had the directory paths listed among some other things, there was also the line $this->caching = true;. While it's not identical to the lines you had given examples of before, I did set it to FALSE and now things seem to be working okay. I guess that was overwriting the default setting or something. Confused
Back to top
View user's profile Send private message Visit poster's website AIM Address
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