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

Caching problem (pages stay beeing cached)
Goto page 1, 2  Next
 
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
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Wed Aug 20, 2003 11:14 pm    Post subject: Caching problem (pages stay beeing cached) Reply with quote

Today I've uploaded my website from my local server to my online one. Now I wanted to change some files, so I made some changes and I uploaded them. But then I got in a shock Shocked Smile the pages where all still the same. Ofcourse the first thing I did is deleting all the IE cache, and then I remembered that Smarty also uses caching, so I tried $smarty->clear_all_cache(); but it didn't work, then I tried a couple other things, clear_cache and $cache_lifetime, also $smarty->cache = 0;

But nothing worked, I still got the same pages, I tried and tried and tried EVERYTHING Shocked Mad

Since I've read all forum topics about caching I noticed that some folks uses a /cache/ dir, so I created it, but still nothing. I also chmodded the template and template_c dirs to 777 (very risky, but I had to try something).

Before I uploaded all files to my online server everything worked fine, no problems at all, but now it's kinda screwed up.

Can anyone help me with this ? Idea Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mocean
Smarty Rookie


Joined: 21 May 2003
Posts: 30
Location: The Netherlands

PostPosted: Thu Aug 21, 2003 10:17 am    Post subject: Reply with quote

The cache files are stored somewhere, that's for sure. The look like
9^^20^p0^db%3A1
You'll see your cache key

You can try deleting these files, together with the compiled templates in template_c.

Perhaps is your problem related to the write permissions of the apache user. Thoug it is strange if apache can compile the templates once (and write them to disk) but cannot overwrite them later.
_________________
Visit My Smarty Enabled Website (Dutch Only) at www.habiforum.nl
and read how it works.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Thu Aug 21, 2003 10:51 am    Post subject: Reply with quote

Hoi Mocean Smile

Well I checked my cache directory but it's totally empty. Also I didn't have a cache directory first, I had to create it manually (kinda strange that smarty didn't include this directory..)

Again today I've been busy for hours to fix this problem, I also tried this:

$smarty->template_dir = '/home/strui013/www/templates/';
$smarty->compile_dir = '/home/strui013/www/templates_c/';
$smarty->config_dir = '/home/strui013/www/configs/';
$smarty->cache_dir = '/home/strui013/www/cache/';
$smarty->caching = false;

But still I've got the same problem, the page just don't want to uncache Evil or Very Mad

I chmodded every directory to 777 for testing purposes, doesn't make any difference at all Confused
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
messju
Administrator


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

PostPosted: Thu Aug 21, 2003 11:01 am    Post subject: Reply with quote

did you flush your templates_c?

you need $smarty->clear_compiled_tpl(), not $smarty->clear_all_cache().

also: smarty needs write-permissions in templates_c to be able to recompile your templates.

don't upload the contents of templates_c from your development-server. start with an empty templates_c and let smarty compile it's templates on the production server.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Thu Aug 21, 2003 11:01 am    Post subject: Reply with quote

And wat I really don't understand is that I've disabled caching but the pages still are beeing cached Sad

URL to this page btw is http://www.driverfiles.net/index.php?page=upload&ID=1
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Thu Aug 21, 2003 11:06 am    Post subject: Reply with quote

Does your ISP perhaps run some sort of proxy cache like squid?
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Thu Aug 21, 2003 11:06 am    Post subject: Reply with quote

Messju, I will try this now and give you feedback. Thank you for your reply Smile And yes I did chmod 777 almost every directory.

AZTEK, nope I don't think so, because without using Smarty nothing got cached whatsoever..


Last edited by driverfiles on Thu Aug 21, 2003 11:07 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
messju
Administrator


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

PostPosted: Thu Aug 21, 2003 11:07 am    Post subject: Reply with quote

driverfiles wrote:
And wat I really don't understand is that I've disabled caching but the pages still are beeing cached Sad


you don't use "caching", but you use "compiling". smarty compiles the templates from your temlates-dir and writes the results into templates_c. if you change your .tpl file, but smarty cannot write into templates_c, your templates' output won't change. there is zero caching involved here.

did you set php's error_reporting to E_ALL and display_errors to true?
are any errors displayed on the page? did you overwrite $smarty->compile_check?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Thu Aug 21, 2003 11:09 am    Post subject: Reply with quote

Smile please hang on messju, I'm now first trying the first things you told me to do.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Thu Aug 21, 2003 11:13 am    Post subject: Reply with quote

Hi,
it's weired you didn't had $cache_dir set up in advance and Smarty didn't yell at you -- at least on a unix box...
it seems like your compiled templates don't get updated, so even without explicit caching you'll see the compiled files. As they contain (older) cache information, changing cache=0 later will not aplly to these "old" files.

You may aslo have missed to provide a compile_id for display() and Smarty reuses the same file over and over again, even if you're sure the content must have changed. (I ran into this on my first day with Smarty)

If you have one single "index.tpl" which is rendering all the pages, you should at least provide things like the REQUEST_URI or the filename you {include} as the compile_id/cache_id to make sure Smarty creates inidividual files for each:
$smarty->display('layout.tpl', $_SERVER['REQUEST_URI'])
or with different php files
$smarty->display('layout.tpl', $PHP_SELF);

In general you should also have four directories defined whereas /cache and /template_c must be writable by Smarty (~ webserver). Using 777 is not necessarily risky if you put all the paths outside of your document root.
Most ISP allow you to change the document root to some other subdirectory of your webspace. In such cases, I usually reserve the "webspace root" for my script base (eg. Pear, Smarty) and move the document root for each domain into some subdirectory therein. This allows me to share the PHP script base among them.
However, here's some small demonstrational setup incl. Smarty settings
[php:1:44753013fb]// DOCUMENT_ROOT = "/user/htdocs/website";
$script_base = "/user/htdocs/scriptbase";
$smarty_dirs = "/user/htdocs/smarty";
include $script_base . "/Smarty/Smarty.class.php";
$smarty = new Smarty();
...
$smarty->template_dir = $smarty_dirs ."/tpls";
$smarty->config_dir = $smarty_dirs ."/configs";
$smarty->cache_dir = $smarty_dirs ."/cache"; // may need 777
$smarty->compile_dir = $smarty_dirs ."/template_c"; // may need 777
...
$smarty->caching = 1; // use cache
$smarty->cach_lifetime = 3600; // 1h or less|more
[/php:1:44753013fb]
I wrote "may need 777" because on some systems a stricter value will do without causing annoyances when you update the files via ftp, eg. 664/666.

I also have some "kickit.php" to wipe everything out. You won't have these lines permanently in your script (!!), but if you make some massive changes to your templates it'll be the best to clear the old files Smarty created.
[php:1:44753013fb]<?php
// this will free the cached/compiled files
$smarty->clear_all_cache(0);
$smarty->clear_compiled_tpl();
?>[/php:1:44753013fb]
You may also force re-compilation of individual pages with a simple condition in your PHP script, so if you want some particular page to be recreated, just add sth. like ?kickit=yup to the URL [php:1:44753013fb]if ($_REQUEST['kickit']) { // brute force attack on Smarty's output
$smarty->force_recompile = TRUE;
$smarty->cache = 0;
$smarty->clear_cache('layout.tpl');
$smarty->clear_compiled_tpl('layout.tpl');
}
...
$smarty->display( ... );
[/php:1:44753013fb]

Have fun,
CirTap
Back to top
View user's profile Send private message
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Thu Aug 21, 2003 11:15 am    Post subject: Reply with quote

I now did the first things you said and it seems to work, I deleted the directories within templates_c and I setted $smarty->clear_compiled_tpl(); and now it updates itself. I only hope that if I need any updating that I don't have to delete those directories every time.

One offtopic question, I now manually added the directory cache, but do I supposed to do this, or does this normally been included in the smarty package ?
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
messju
Administrator


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

PostPosted: Thu Aug 21, 2003 11:17 am    Post subject: Reply with quote

@CirTap: knock, knock! driverfiles doesn't use any caching at all!

BTW: there is no $smarty->force_recompile (it's called force_compile) and there is no $smarty->cache (i think you mean $smarty->caching);
Back to top
View user's profile Send private message Send e-mail Visit poster's website
driverfiles
Smarty Rookie


Joined: 10 Aug 2003
Posts: 26
Location: Epe, The Netherlands

PostPosted: Thu Aug 21, 2003 11:21 am    Post subject: Reply with quote

Thank you soooooooo much for your help guys! I was busy with this problem for hours, you really helped me out here, thanx !! Smile

I tried out a couple of updates on the same template and it works excellent! Smarty is the best! Smile

@CirTap: Thank you for your great tips, I will try them out.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Thu Aug 21, 2003 11:55 pm    Post subject: Reply with quote

messju wrote:
@CirTap: knock, knock! driverfiles doesn't use any caching at all!
BTW: there is no $smarty->force_recompile (it's called force_compile) and there is no $smarty->cache (i think you mean $smarty->caching);

yes, sorry for the "typos"... force_recompile, force_compile - cache, caching, cache_dir ... %-/ I was still with my first cup'o'coffee, so pleeze forgive me.

interesting phenomenon anyway: when I opened this Q there was no response at all and I'm pretty sure it didn't take me *an hour* to write this.

CirTap
Back to top
View user's profile Send private message
mikeken
Smarty Regular


Joined: 13 Aug 2003
Posts: 57
Location: MN

PostPosted: Fri Aug 22, 2003 1:43 pm    Post subject: Reply with quote

I am having the same problem because I have a dynamic site which users can update there profile and it can be viewed also, but I have to refresh in order for it to update. Do I have to delete everything my my templates_c

Or is this something else?
Back to top
View user's profile Send private message Send e-mail 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
Goto page 1, 2  Next
Page 1 of 2

 
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