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

how to cache with two variables ?view=index&id=10

 
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
johannes
Smarty Regular


Joined: 10 May 2003
Posts: 85
Location: Malmö, Sweden

PostPosted: Sat May 10, 2003 11:40 am    Post subject: how to cache with two variables ?view=index&id=10 Reply with quote

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 Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat May 10, 2003 11:47 am    Post subject: Reply with quote

$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
View user's profile Send private message
dthought
Smarty Regular


Joined: 21 Apr 2003
Posts: 55
Location: Melbourne, Australia

PostPosted: Sat May 10, 2003 2:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sat May 10, 2003 5:39 pm    Post subject: Reply with quote

more than 100ms are not really acceptable if you ask me... Smile

-edit-
well, okay, let's say 500ms, but that's the VERY upper threshold...
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


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

PostPosted: Sat May 10, 2003 6:56 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat May 10, 2003 6:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
Wom.bat
Smarty Pro


Joined: 24 Apr 2003
Posts: 107
Location: Munich, Germany

PostPosted: Sun May 11, 2003 3:21 am    Post subject: Reply with quote

I mostly set cache_lifetime to "-1" and delete the cache when changes are made...
Back to top
View user's profile Send private message
johannes
Smarty Regular


Joined: 10 May 2003
Posts: 85
Location: Malmö, Sweden

PostPosted: Sun May 11, 2003 10:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun May 11, 2003 11:19 pm    Post subject: Reply with quote

johannes, can you post a code sample?
Back to top
View user's profile Send private message
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