|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
nlenz Smarty n00b
Joined: 15 Aug 2003 Posts: 1
|
Posted: Fri Aug 15, 2003 4:57 pm Post subject: how to create a cache_id tip |
|
|
Something I figured out... if you need a cache_id that you don't want to worry about in the future:
$cache_id = md5($_SERVER['REQUEST_URI']);
or
$cache_id = md5('mything'.$_SERVER['QUERY_STRING']);
This way when you add something to your page in the future, say a printer friendly version by appending &printer=1 to the query string then you don't have to worry about keeping track of every little id that changes your page.
Of course this doesn't work in every situation.
One question though,...why doesn't smarty automatically take the QUERY_STRING into account when displaying a cached template (when not given a cache_id).
So if this code was executed with the following url's,...shouldn't they automatically return different caches?
$s->caching = true;
$s->display('coolpage.tpl');
http://somesite/coolpage.php?cool_thing=2
http://somesite/coolpage.php?cool_thing=3
Just some thoughts.... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Aug 15, 2003 7:10 pm Post subject: Re: how to create a cache_id tip |
|
|
nlenz wrote: |
$cache_id = md5('mything'.$_SERVER['QUERY_STRING']);
|
That works so long as you want the entire QUERY_STRING to affect the page caching. FYI, you are still vulnerable to flood attacks filling up your hard disk with bogus cache files. Maybe some more strict checking should be implemented.
nlenz wrote: |
One question though,...why doesn't smarty automatically take the QUERY_STRING into account when displaying a cached template (when not given a cache_id).
|
That behavior would be application independent, not something smarty should assume. |
|
Back to top |
|
datamile Smarty Rookie
Joined: 17 May 2003 Posts: 13
|
Posted: Tue Aug 19, 2003 9:21 pm Post subject: |
|
|
Never thought of that...
Normally build the cache id from the required parameters of the page , and then pass it to a translating routine which generates an ID in a mysql data if the cache id is over a certain lenght |
|
Back to top |
|
|
|
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
|