Development

#4246 (Action cache does not work after action forward)

You must first sign up to be able to contribute.

Ticket #4246 (new defect)

Opened 5 years ago

Last modified 3 years ago

Action cache does not work after action forward

Reported by: eXtreme Assigned to: fabien
Priority: major Milestone:
Component: cache Version: 1.4.1
Keywords: cache, view, action, forward Cc:
Qualification: Unreviewed

Description

Symfony cannot cache forwarded action. It always wants to cache base action which is not good for me. I have one main Article/Show action which always forwards to another Article actions basing on article type (from DB), for example: homepage, news, gallery and so on - so it is obvious I don't want to cache article/show but each single action. But it's impossible. In cache.yml I have "enabled: off" for "show" and "enabled: on" for some actions I want to have cached.

And I know why it can't work. sfPHPView::render() sends internal URI to sfViewCacheManager::getActionCache(). In fact this internal URI is based on routing ($this->context->getRouting()->getCurrentInternalUri()) not on exact module/action which executes view render.

This internal URI points always to article/show (because I have route which sends requests to this action) - not to my forwarded actions (like article/homepage)!

Of course when I enable cache for article/show Symfony does not really know about forwarded actions so it fails also on component slots (I have different sidebars for each forwarded action) and I can't control when to cache and when not to cache. That's why I can't cache article/show.

Attachments

sfForwardCacheFilter.class.php (2.9 kB) - added by vital on 02/04/10 03:16:12.
my solving this problem

Change History

09/25/08 20:36:37 changed by eXtreme

  • version changed from 1.1.0 to 1.1.2.

10/14/08 14:28:25 changed by eXtreme

  • version changed from 1.1.2 to 1.1.4.

01/21/10 17:45:29 changed by rambam

  • version changed from 1.1.4 to 1.4.1.

Some experiments showed me similar effects (with the same cause?) in symfony 1.4.1.

Secured action displays login form after login, and the login form displays the (secured) page after logout.

02/04/10 03:16:12 changed by vital

  • attachment sfForwardCacheFilter.class.php added.

my solving this problem

02/04/10 03:18:51 changed by vital

in filters.yml

cache:
  class: sfForwardCacheFilter