cache+dynamic site - i don't get it...
| From: | k | Date: | Wed, 01 May 2002 23:00:52 +0000 |
| Subject: | cache+dynamic site - i don't get it... | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3968@lists.php.net to get a copy of this message | ||
[posted this to the php.smarty.general newsgroup, but did not show up - but sorry if it shows up two
times]
Hi,
I have started using Smarty a few days ago. I've used PHP and other template systems before.
So - I think - I've understood the main concept of Smarty, and I can create pages with
templates.
My problem is that I don't understand the "relation" of the cache feature and dynamic
content.
The way I use Smarty now is the following:
1. gather data from database(s), put it in arrays, etc.
2. assign data to Smarty/template variables [assign()]
3. use display() to send the html out.
My question: if I turn caching on, the 1st step above (get data from mysql database, put it in
arrays, etc) will still be executed?
(My goal is to run this part only once, only when data has changed.)
If it's still executed, how sould I write the code, to avoid redundant db access?
I know I can give a cache ID to the display() function, based on the GET vars (query_string),
I've found the "insert" function (and use it for the banner), but things just
don't come together in my head :O
[A few notes about my site. I hope You don't mind if I explain it's
structure a bit...
I. static header
II. a box with list of various items (names + values)
III. search form + search result box
IV. static footer
I. and IV. are OK, these are in header and footer.tpl.
II. contains data that only changes a few times in a month. So I really
don't want to generate it on every visit (pageview).
I was thinking about generating it with another script, and use it as a
(sub)template, but that would not be the "Smarty way".
III.: search results and detailed information.
This part can change with every pageview.
So, this site is something like a link-index page: you can click on
categories, than you get the links in that category, and you can view the description of an item
with another click.
Category names don't change every day (but change sometimes), OTOH the
results box have to be generated on the fly.]
TIA, and excuse me for the long post.
regards,
k