View previous topic :: View next topic |
Author |
Message |
johannes Smarty Regular
Joined: 10 May 2003 Posts: 85 Location: Malmö, Sweden
|
Posted: Sat May 10, 2003 11:40 am Post subject: how to cache with two variables ?view=index&id=10 |
|
|
Hi there
I have some caching problem to sort out. When I use one variable 'view', it is working fine but when I want to use two variables 'view' and 'id' then i make no sense and wont work for mee. So - is it possible to cache the page as an unique page and use more then one variable? How to?
Exampels:
This is ok, no problem
index.php?view=index
index.php?view=poet
index.php?view=sport
All these creates unique cached files i folders like index,poet, sport
but like this I wont work for mee?
index.php?view=index&id=10
index.php?view=index&id=11
index.php?view=index&id=12
Greatful for tips on how too set up the cahe. Thansk and have a nice weekend. Me - Im heading for dinner by the North atlantic In Sweden |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat May 10, 2003 11:47 am Post subject: |
|
|
$cacheid = "$view";
if (!empty($id))
$cacheid .= "|id$id";
so $cacheid becomes....
"index", "poet", "sport" and "index|id10", "index|id11", "index|id12", etc.
The "|" is the separator for multiple cacheid's.
I prefixed the id # with "id" because it makes more sense and allow you to add other numerical caches.
Warning: use this technique judiciously unless you have a lot of disk space to store all the cache files!! |
|
Back to top |
|
dthought Smarty Regular
Joined: 21 Apr 2003 Posts: 55 Location: Melbourne, Australia
|
Posted: Sat May 10, 2003 2:35 pm Post subject: |
|
|
boots wrote: | Warning: use this technique judiciously unless you have a lot of disk space to store all the cache files!! |
Sage advice. Unless your pages are taking more than 2 seconds to render (not download), time really shouldn't be too much of an issue, |
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Sat May 10, 2003 5:39 pm Post subject: |
|
|
more than 100ms are not really acceptable if you ask me...
-edit-
well, okay, let's say 500ms, but that's the VERY upper threshold... |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat May 10, 2003 6:56 pm Post subject: |
|
|
Hell the speed all depends on what machine your running your scripts on i get between 0.02 and 0.5 seconds all depending on how much ram and what processor speed the server is and also what operating system. _________________ "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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat May 10, 2003 6:59 pm Post subject: |
|
|
It really comes down to tuning. There is obviously NO point in caching a page that is only viewed once during the cache lifetime-even if it takes 10s to generate the page. It only eats resources and causes additional time for the cache cleanup cycle.
On the other hand, you don't want to regenerate often viewed pages. i made the point since johannes didn't indicate how the multi variable usage was designed or if there were more vars etc.
So to sum up: caching is a tool which is only properly used if you know what you are using it for. |
|
Back to top |
|
Wom.bat Smarty Pro
Joined: 24 Apr 2003 Posts: 107 Location: Munich, Germany
|
Posted: Sun May 11, 2003 3:21 am Post subject: |
|
|
I mostly set cache_lifetime to "-1" and delete the cache when changes are made... |
|
Back to top |
|
johannes Smarty Regular
Joined: 10 May 2003 Posts: 85 Location: Malmö, Sweden
|
Posted: Sun May 11, 2003 10:12 pm Post subject: |
|
|
hi and thanks , this is the way I used but. the stange thing is that Smaty is caching the three first viewed pages correct but the rest is false.
ehe I mean -> the three first viewed pages i cached perfekt but when i click on the next number 4,5 and so on the get the same look as one of the earlier ones?
But if I leav out the view-variable and just use the id as cacheid the pages is cached totaly perfekt. hmm...
[quote="boots"]
$cacheid = "$view";
if (!empty($id))
$cacheid .= "|id$id";
quote] |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun May 11, 2003 11:19 pm Post subject: |
|
|
johannes, can you post a code sample? |
|
Back to top |
|
|