Re: Cache question
Call $this->disableCache(); for sensitive actions. Or call it always when logged in. On Oct 11, 11:33 pm, "Dave Maharaj :: WidePixels.com" wrote: > I have an element that when the user logs in says Welcome Test Account One > (being my dummy user's name) > > I logout and login as a different user and it shows Welcome Test Account One > until i hit refresh then it shows Test Account Two > > I have wrapped the element in a block. > > Logout destroy session but same thing. It always shows the last logged in > user info until i hit refresh. > > Same thing happens on the site where i delete a post, after succesful delete > i redirect back to the page where i was deleting the post and its still > there until i refresh. And it to is wrapped in a no cache block. > > Any ideas why? How to avoid this? > > Thanks, > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
RE: Cache question
Firefox believe it or not. -Original Message- From: euromark (munich) [mailto:dereurom...@googlemail.com] Sent: October-11-09 2:15 PM To: CakePHP Subject: Re: Cache question did you experience that in the almighty crap-explorer IE? On 11 Okt., 18:33, "Dave Maharaj :: WidePixels.com" wrote: > I have an element that when the user logs in says Welcome Test Account > One (being my dummy user's name) > > I logout and login as a different user and it shows Welcome Test > Account One until i hit refresh then it shows Test Account Two > > I have wrapped the element in a block. > > Logout destroy session but same thing. It always shows the last logged > in user info until i hit refresh. > > Same thing happens on the site where i delete a post, after succesful > delete i redirect back to the page where i was deleting the post and > its still there until i refresh. And it to is wrapped in a no cache block. > > Any ideas why? How to avoid this? > > Thanks, > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cache question
did you experience that in the almighty crap-explorer IE? On 11 Okt., 18:33, "Dave Maharaj :: WidePixels.com" wrote: > I have an element that when the user logs in says Welcome Test Account One > (being my dummy user's name) > > I logout and login as a different user and it shows Welcome Test Account One > until i hit refresh then it shows Test Account Two > > I have wrapped the element in a block. > > Logout destroy session but same thing. It always shows the last logged in > user info until i hit refresh. > > Same thing happens on the site where i delete a post, after succesful delete > i redirect back to the page where i was deleting the post and its still > there until i refresh. And it to is wrapped in a no cache block. > > Any ideas why? How to avoid this? > > Thanks, > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cache Question
Caching is basically required for any data-heavy or interaction-heavy site... but you need to be in control of who gets what cache; more specifically, you need to be sure people only get their own cached content. Cake < 1.2 has caching... great caching if your contact is the same for everyone... but it's less than ideal for per-user content... in fact if you wanted to cache the "public" version of a view, and ignore cache >userid; and even for one site an additional parameter: $this- >repid. The cache file name defaults to starting with the current controller_action... but they can be arbitrarily set (which is how I use it most of the time). Feel free to add other parameters, if you need to split your caches by other things... for me, I just needed a unique cache per userid and per repid. Controller Class: userid = $this->myAuthenticaitonSystem(); // populating value with a number, so we can discuss in this example. $this->userid = 42; // mockup value! // initialize Ecache $this->Ecache->startup($this); } /** * simple ecache example. just a regular database data result cached. * cache filename will be: ./app/tmp/cache/views/ users_list_0_42_0.php * if $this->userid was 89, the cache filename would be: ./app/tmp/ cache/views/users_list_0_89_0.php */ function example1() { // checking cache $d = $this->Ecache->ecache(null,'users','list'); // if missing cached content if (empty($d)) { // now get cached content $cond = array('User.parent_id'=>$this->userid); $results = $this->User->findAll($cond); // writing cache $d = $this->Ecache->ecache($results,'users','list'); } $this->set('myusers',$d); } /** * there are 2 differnt cache calls in this example. * the first is like above, based on the $this->userid. * cache filename will be: ./app/tmp/cache/views/ users_pageelement_0_42_0.php * if $this->userid was 89, the cache filename would be: ./app/tmp/ cache/views/users_pageelement_0_89_0.php * the second will cache content globally (not on a per-user basis) * cache filename will be: ./app/tmp/cache/views/ users_pageelement_0_global_global.php * notice that the content in this example is generated from returned "requestAction"s */ function example2() { // checking cache $d = $this->Ecache->ecache(null,'users','pageelement'); // if missing cached content if (empty($d)) { // now get cached content $results = $this->requestAction('/something/ action',array('return')); // writing cache $d = $this->Ecache- >ecache($results,'users','pageelement'); } $this->set('user_specific_content',$d); // checking cache $d = $this->Ecache->ecache(null,'users','pageelement', 0,'global','global'); // if missing cached content if (empty($d)) { // now get cached content $results = $this->requestAction('/anything/ content',array('return')); // writing cache $d = $this->Ecache->ecache($results,'users','pageelement', 0,'global','global'); } $this->set('global_content',$d); } /** * This is simply a convenience wrapper for clearing the cache files. * clearing cache deletes: ./app/tmp/cache/view/* * ...often you may need to clear from a model, afterSave() */ function exampleClear() { $this->Ecache->clear(); } } ?> Obviously, the above examples were simple. If you had a huge database query it might be worth it to cache, or if you used the same content a lot... most of the time though, caching is really useful for multiple database operations, heavily processed data, or returned "requestAction" data. Component Class: http://www.opensource.org/licenses/mit-license.php The MIT License * * == Info == * caches arrays or strings... good for $this->requestEvent(), and just as good for a Database Query Result Set... * * version below includes optional fields: $controller, $action, $id, $userid, $repid * most of those fields inherit from the controller if empty... (left the code as simple as possible for easy reconfiguration) * * Can clear at any point with cake helper function: clearCache(); */ class EcacheComponent extends Object { var $duration = '+2 hours'; var $controller, $id, $userid, $repid; // may be used later function startup(&$controller) { $this->controller = &$controller; if (isset($this->controller->id)) { $this->id = $this->controller->id; } if (isset($this->controller->Uid)) { $this->userid = $this->controller->Uid; } if (isset($this->controller->repid)) { $this->repid = $this->controller->repid; } } function ecache($data=null, $controller=null, $action=null, $i
Re: Cache Question
On 8/7/07, MattC <[EMAIL PROTECTED]> wrote: > > Feris, > You could try putting your code in the constructor for your > controller. I'm not sure if this is even possible though, since the > controller gets called from the cache file itself, so deleteing the > cache file at this point may already be too late. > > -Matt > www.pseudocoder.com > Hi Matt, Yes, indeed it's too late. It always call the cache first to check the expiration before going to the controller. Is there any reference how CakePHP bootstrap works ? Especially regarding cache mechanism ? Thanks ! Feris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cache Question
Feris, You could try putting your code in the constructor for your controller. I'm not sure if this is even possible though, since the controller gets called from the cache file itself, so deleteing the cache file at this point may already be too late. -Matt www.pseudocoder.com On Aug 6, 1:04 pm, "Feris Thia" <[EMAIL PROTECTED]> wrote: > Hi All, > > I have in my controller a caching of one of my view and cache > deletion mechanism in beforeFilter, I know it doesn't make sense... > but just try to add to see what is going on. > > --- > var $cacheAction = array( > 'detail/' => 21600 > ); > > function beforeFilter() > { > clearCache('detail/');} > > --- > > The cache is perfectly created but seems like it never goes to my > controller again and skip beforeFilter mechanism. > > How do I enable cache but also can do the deletion of the cache at > some conditions I specify before loading the cache view ? > > Regards, > > Feris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---