Hi Georg,

the second solution is exactly what we needed. Thank you very much.

Cheers,
Lea

On Jul 26, 2010, at 13:01 , Georg wrote:

> Lea,
> 
> I think this happens:
> if the user is not authenticated, the page is added to the cache by your
> ConditionalCacheFilter. And if withLayout is set, the cache sets a cache
> expiry time in the http header that is equal to the ttl
> (sfCacheFilter::setCacheExpiration()).
> Now the user logs in, and the user is redirected to the homepage. But
> firefox recognizes the url, and has a ttl of one hour for it, so does
> not request the page again.
> 
> You have two choices IMO:
> 
> 1) Let the client cache the page and use another route for the homepage
> action for logged in users (@loggedInHomepage):
> cache.yml
> homepage:
>  enabled: true
>  with_layout: true
> 
> loggedInHomepage:
>  enabled: false
> and redirect the user to @loggedInHomepage in the action if he/she is
> not coming through this route.
> 
> The advantage of this is that the browser has two urls, where one is
> cached and the other not by the browser (reducing the server load
> further and speeding up the user experience, and you can drop your
> ConditionalCacheFilter and use vanilla symfony cache)
> 
> 2) Let the server do the caching:
> change your ConditionalCacheFilter to use the addCache method with the
> clientLifeTime parameter set to 0:
> $cache->addCache($page['module'], $page['action'], array('lifeTime' =>
> $page['ttl'], 'withLayout' => $page['withLayout'], 'clientLifeTime' => 0));
> (hmm, reading sfCacheFilter::setCacheExpiration(), I am not sure if this
> works, maybe you should should set clientLifeTime to 1 (nobody can login
> in less then one second ;-), check for yourself)
> 
> This means the the client will always request the page again, and
> symfony serves if from it's cache as long as the user is not logged in
> (which I guess whas the intended behaviour by you)
> 
> HTH Georg
> 
> Am 26.07.2010 12:04, schrieb Lea Hänsenberger:
>> No, we use a filter class. The filter.yml entry is the following:
>> 
>> conditionalCache:
>>  # all pages added to this are cached only for anonymous users
>>  class: ConditionalCacheFilter
>>  param:
>>    pages:
>>      - { module: home, action: index, ttl: 3600, withLayout: true }
>> 
>> The ConditionalCacheFilter class looks like this:
>> 
>> class ConditionalCacheFilter extends sfFilter
>> {
>>  public function execute($filterChain)
>>  {
>>    $context = $this->getContext();
>> 
>>    if (($cache = $context->getViewCacheManager()))
>>    {
>>      if (!$context->getUser()->isAuthenticated())
>>      {
>>        foreach ((array)$this->getParameter('pages') as $page)
>>        {
>>          if (!isset($page['withLayout']))
>>          {
>>            $page['withLayout'] = false;
>>          }
>>          $cache->addCache($page['module'], $page['action'], array('lifeTime' 
>> => $page['ttl'], 'withLayout' => $page['withLayout']));
>>        }
>>      }
>>    }
>>    // Execute next filter
>>    $filterChain->execute();
>>  }
>> }
>> 
>> On Jul 26, 2010, at 11:58 , Georg wrote:
>> 
>>> Do you have with_layout: true in your cache.yml?
>>> 
>>> Am 26.07.2010 11:17, schrieb Lea Hänsenberger:
>>>> Hi Georg,
>>>> 
>>>> Ok, I tried with disabling all the firefox addons, clearing the cache and 
>>>> sending the cache headers in both the homepage action and the login 
>>>> action. I encountered the same behaviour.
>>>> If I check the http response on the login page I see the headers I sent. 
>>>> On the homepage they seem to be overwritten by the cache filter. 
>>>> After the login I'm being redirected to the homepage, but the homepage is 
>>>> not re-requested from the server anymore (in firebug's net tab there is no 
>>>> request to the homepage).
>>>> 
>>>> Cheers,
>>>> Lea
>>>> 
>>>> On Jul 26, 2010, at 10:54 , Georg wrote:
>>>> 
>>>>> Lea,
>>>>> 
>>>>> does this happen also on a firefox out of the box (meaning have you some
>>>>> add-ons that mess up your firefox's cache?) because I do not expirience
>>>>> this behaviour.
>>>>> And are you sending the cache headers on the homepage before login?
>>>>> And have you cleared the firefox's cache before doing another test?
>>>>> I know, simple things, just to be sure...
>>>>> 
>>>>> HTH Georg
>>>>> 
>>>>> Am 26.07.2010 10:28, schrieb Lea Haensenberger:
>>>>>> Hi,
>>>>>> 
>>>>>> I just tried that, it didn't change anything.
>>>>>> 
>>>>>> On Jul 23, 1:16 am, Gustavo Adrian <[email protected]>
>>>>>> wrote:
>>>>>>> Hi,
>>>>>>> 
>>>>>>> Did you try to disable local caching on the action with headers
>>>>>>> "Cache-control" and "Pragma" to see what happens?
>>>>>>> 
>>>>>>> $this->getResponse()->setHttpHeader("Cache-Control", "no-cache");
>>>>>>> $this->getResponse()->setHttpHeader("Pragma", "no-cache");
>>>>>>> $this->getResponse()->setHttpHeader("Expires", 0);
>>>>>>> 
>>>>>>> On Thu, Jul 22, 2010 at 11:37 AM, Lea Haensenberger 
>>>>>>> <[email protected]>wrote:
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>>> I found out that when disabling the memory cache in firefox or when
>>>>>>>> setting check.doc_frequency to 1, i.e. request page on every load,
>>>>>>>> everything works fine. doc_frequency is usually set to 3, i.e. check
>>>>>>>> validity of the page by looking at the modified date and reload if
>>>>>>>> necessary, and the modified date changes when going back to the
>>>>>>>> homepage but the page is not actually reloaded.
>>>>>>> 
>>>>>>>> Maybe with that additional information someone can help me solve that
>>>>>>>> problem!?
>>>>>>> 
>>>>>>>> Cheers,
>>>>>>>> Lea
>>>>>>> 
>>>>>>>> On Jul 22, 10:42 am, Lea Haensenberger <[email protected]> wrote:
>>>>>>>>> Does nobody know that problem? I'm a bit lost and I'll have to turn
>>>>>>>>> offcachingif we can't solve the problem.
>>>>>>>>> Does anyone have any idea what could be the reason for that behaviour?
>>>>>>> 
>>>>>>>>> Lea
>>>>>>> 
>>>>>>>>> On Jul 16, 3:52 pm, pghoratiu <[email protected]> wrote:
>>>>>>> 
>>>>>>>>>> Do you have this behavior also with the development controller
>>>>>>>>>> (frontend_dev.php)?
>>>>>>> 
>>>>>>>>>> gabriel
>>>>>>> 
>>>>>>>>>> On Jul 16, 4:09 pm, Lea Haensenberger <[email protected]> wrote:
>>>>>>> 
>>>>>>>>>>> I've encountered a strange problem with firefox andcaching. When I
>>>>>>>>>>> log in and get redirected to the homepage afterwards I don't see 
>>>>>>>>>>> that
>>>>>>>>>>> I'm logged in. If I have a look at
>>>>>>>> context->getUser()->isAuthenticated() I get 'false'. After manually
>>>>>>>> reloading the
>>>>>>> 
>>>>>>>>>>> homepage everything is fine. I already tried invalidating the cache
>>>>>>>> on
>>>>>>>>>>> log in, doesn't help.
>>>>>>>>>>> It works fine in Safari.
>>>>>>>>>>> Does anyone have an idea what happens with firefox here?
>>>>>>> 
>>>>>>>>>>> Cheers,
>>>>>>>>>>> Lea
>>>>>>> 
>>>>>>>> --
>>>>>>>> If you want to report a vulnerability issue on symfony, please send it 
>>>>>>>> to
>>>>>>>> security at symfony-project.com
>>>>>>> 
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "symfony users" group.
>>>>>>>> To post to this group, send email to [email protected]
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> [email protected]<symfony-users%2bunsubscr...@goog
>>>>>>>>  legroups.com>
>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/symfony-users?hl=en
>>>>>> 
>>>>> 
>>>>> -- 
>>>>> If you want to report a vulnerability issue on symfony, please send it to 
>>>>> security at symfony-project.com
>>>>> 
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "symfony users" group.
>>>>> To post to this group, send email to [email protected]
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/symfony-users?hl=en
>>>> 
>>> 
>>> -- 
>>> If you want to report a vulnerability issue on symfony, please send it to 
>>> security at symfony-project.com
>>> 
>>> You received this message because you are subscribed to the Google
>>> Groups "symfony users" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/symfony-users?hl=en
>> 
> 
> -- 
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
> 
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to