Re: Please help on caching
| From: | Brian E . Lozier | Date: | Fri, 28 Dec 2001 11:07:09 +0000 |
| Subject: | Re: Please help on caching | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2398@lists.php.net to get a copy of this message | ||
Have you gotten a method like this to work with a login system? The problem I've just run into
is that if
the first person to visit is logged in, the cached pages shows everyone following as logged in.
*sigh* I
wish there was a way to only cache certain templates that are retrieved via ->fetch(). Or that
my cache
would actually store two files... the 'main.tpl' (outer shell) and then the inner content
itself. Then I
could cache the content (inner) and not the outer, which doesn't depend on db calls anyway.
I guess the way this system is set up is that in order to use caching, you have to separate your
design into
multiple files and then use include statements... in which point it doesn't seem to be an
advantage anyway.
Pity I didn't realize this sooner, because 3/4 of my app is done and I'm just now
realizing that the entire
caching system simply doesn't work. Top that off with the fact that some of my pages are
taking up to half a
second to generate, and it makes the whole thing a lot slower than fasttemplate or phplib templates
ever
were.
There needs to be some way to tell smarty to get the cached content for certain templates within a
page but
not others. That way I can specify which parts of the pages I get from a cache and which I
don't. For
instance, I could cache the user comments on each article for an hour, but people should still be
able to add
articles, so I can't cache the add comment FORM itself (because there are hidden elements that
tell the
script which article the person is commenting on). I can cache the main news page that lists all
the news
from the database, but not the outer design because it has feedback letting the user know whether
they're
logged in or not (and displays more options when you're logged in than when you're not).
Being able to cache
certain templates only would be a big help because I could eliminate database calls altogether from
the vast
majority of pages, while still having the logged in feedback and other 'dynamic' content
that simply must be
dynamic.
Brian
------------------------------------
"How should I know if it works? That's what beta testers are for. I only coded it." -
Linus Torvalds
----- Original Message -----
From: Peter Bowyer <reywob@f2s.com>
To: smarty@lists.ispi.net
Date: 12/27/01 3:34:09 AM
>
>At 04:06 PM 12/26/01 -0800, you wrote:
>>I have queried this list quite a few times but nothing is helping. I
>>upgraded to the latest version. I have
>>tried all suggestions. Is this a bug in Smarty? Does anyone else have
>>this "dynamic" content caching
>>correctly using the cache_id? Because Smarty is just ignoring my cache_id
>>I pass, no matter what it is.
>>Please, I really need to get this working, it's important.
>
>I have it working with Smarty 1.4.5 - see it in action at
><http://casualties.commemoratewtc.com> where each page is
>cached for 3 days.
>
>>Here is my 'main.tpl' which is the main layout of the site (note I
>>replaced > and < with ] and [ because my
>>email program strips the HTML for some reason):
>>
>>main.tpl:
>>[html]
>>[head][title]{$PageTitle}[/title][/head]
>>[body]
>>{$Content}
>>[/body]
>>[/html]
>
>Great - another coder who hates header/footer files and prefers the design
>to be in one file! That now makes two of us for whom the "normal" smarty
>method doesn't suit :-)
>
>>I have tried passing both $REQUEST_URI (which *is* passing correctly, I
>>verified!) and $catID (since it's
>>unique for each of the cache results I'm looking for) to main.tpl like:
>>$tpl->display('main.tpl', $REQUEST_URI); // and:
>>$tpl->display('main.tpl', $catID);
>>
>>I've also tried passing it to the $tpl->fetch() where I get the actual
>>files.tpl template like:
>>$tpl->assign("Content", $tpl->fetch('files.tpl', $REQUEST_URI));
>
>This is the right one. After this, just call $tpl->display('main.tpl'); and
>it should work. You could always try $tpl->display('main.tpl',
>$REQUEST_URI); as well.
>
>Did you clear the cache and the compiled templates before you tried this?
>
>Sorry I can't be more help.
>Peter.
>
>--
>Maple Design - http://www.mapledesign.co.uk
>
>
>---
>You are currently subscribed to smarty as: brian@massassi.net
>To unsubscribe send a blank email to $subst('Email.Unsub')
>Visit Smarty's homepage at
>http://www.phpinsider.com/php/code/Smarty/