Re: Question about selective caching.

From: Date: Sat, 12 Jan 2002 01:00:05 +0000
Subject: Re: Question about selective caching.
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2525@lists.php.net to get a copy of this message
At 17:35 11/01/02 -0600, Monte Ohrt wrote:
Use your $REQUEST_URI as the cache_id: global $REQUEST_URI; // only if needed $smarty->display($tpl_name,$REQUEST_URI); This will create a separate cache file for each unique URL when you call $tpl_name.
Hello, Sorry to upset with this cache story but I still fail.... I seem to have the same problem than the first time I tried using cache. The caching function works the first time and a (1) cache file is created, but not the other ones and the same page is displayed again and again without consideration of the link ($REQUEST_URI). In my $cache_dir (./cache) there is only one (1) file, the one generated the first time instead of the numerous ones representing the various $REQUEST_URI. 1- $REQUEST_URI works on my ISP server (I did a echo) 2- I have a main template (index.tpl) that I can't cache (because it holds user information) and an internal one 'internal_template.tpl' that I would like to cache based on $REQUEST_URI. Inside index.tpl there is {$center} to place the included 'internal_tempate.tpl' 3- A typical URL is http://www.mydomain.com/members.php?a=list&sex=2&location=1 4- my (buggy) bit of code is : require("Smarty.class.php"); $smarty = new Smarty; $smarty->compile_check = false; $smarty->debugging = false; $smarty->caching = false; global $REQUEST_URI; [...]
        case 'list' :  //echo $REQUEST_URI;
                     $smarty->caching = true;
                           if(!$smarty->is_cached('index.tpl', $REQUEST_URI)) {
                           $smarty->assign("data", $myuserclass->user_getMembers($id,$sex,$location));
                           $center_cache = $smarty->fetch('internal_template.tpl');
                           $smarty->assign('center', $center_cache);
                           $smarty->caching = false;
                           }else {
                            $smarty->assign('center', 'internal_template.tpl');
                      $smarty->caching = false;
                            }
                           $tpl_name ='index.tpl';
                           break;
[...] if(!isset($tpl_name)){$tpl_name ='index.tpl';} $smarty->display($tpl_name,$REQUEST_URI);//$smarty->display($tpl_name);

« previous php.smarty.general (#2525) next »