views:

23

answers:

1

If a certain condition is met, is it possible to tell symfony not to cache the current request? I'm aware of the contextual configuration flag, but this is an action, and not a partial or component, so I don't think it applies.

Context: I'm running a multi-site CMS. Each site can have multiple domain names associated with it, but one is set as the primary. It a page request is made with the alternate domain name, it gets forwarded to the primary. But the action gets cached so when the same url is accessed, it serves the cache file instead of redirecting.

A: 

See here:

http://www.symfony-project.org/book/1_2/12-Caching#chapter_12_sub_configuring_the_cache_dynamically

You can use that approach, modifying the filter class to use whatever conditions you want to enable/disable cache.

The example in the link above disables/enables cache per module/action. You can use:

sfConfig::set('sf_cache', false);

to enable/disable it globally if preferred.

benlumley