/** * Sets the TTL on widget cache after the other cache options have been set, * this allows us to make sure widgets refresh every so often regardless. * * @param WidgetEvent $event */ public function setSharedCache(WidgetEvent $event) { // Not cacheable, don't add anything if (!$event->getResponse()->isCacheable()) { return; } $advancedSettings = $this->settings->load('advanced'); $ttl = $advancedSettings->get('widget_max_age'); // Set max lifetime for widgets $event->getResponse()->setSharedMaxAge($ttl); }
public function setStrategyCache(WidgetEvent $event) { $widget = $event->getWidget(); $cacheOptions = $event->getStrategy()->getCacheOptions($widget); // Set options on response $event->getResponse()->setCache($cacheOptions); }