0

Is it possible to set the sf_cache_key in the components action? Normally it's done in the component call:

include_component('default', 'navi', array('sf_cache_key' => 'my_cache_key'));

But I need to generate it out of the "navi"-action.

Ref: contextual caching of templates with components

I solved this problem by generating the cache key in seperate filter and save it to sfConfig:

include_component('default', 'navi', array('sf_cache_key' => sfConfig::get('my_cache_key')));
Community
  • 1
  • 1
ownking
  • 1,956
  • 1
  • 24
  • 34

1 Answers1

1

When the component is called second time its result is already in cache. Component's code is not called second time. It's the whole idea of caching. Generating cache key inside the code which needs to be cached misses the point.

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125