eZ Community » Forums » eZ Publish 5 Platform » Connect controller cache with several...
expandshrink

Connect controller cache with several locations IDs

Connect controller cache with several locations IDs

Sunday 10 February 2013 4:16:47 pm - 11 replies

Hello,

I try to configure a sub request for a menu so that when a node listed in the menu is modified the cache is purged. 

I succeeded to connect my controller with ONE location by using :

 $response->headers->set( 'X-Location-Id', 123 );

When I modifiy the content 123 it expires the menu cache. 

But I can't get an expiration for every location in the menu. 

I tried X-Group-Location-Id but it doesn't work. 

How do you achieve this ? 

 

Thanks

Modified on Sunday 10 February 2013 4:17:19 pm by Matthieu Sévère

Sunday 10 February 2013 4:24:44 pm

Hi Mathieu
You can add several location ids by separating them with commas happy.gif Emoticon

Sunday 10 February 2013 4:35:09 pm

Awesome ! 

Unfortunately it's not working for me, I added this :

 $response->headers->set( 'X-Location-Id', "72,61" );

Note that it's working very well with one Location Id. 

I'll try to investigate...

Does it mean that it's really the good approach when we want to clear a menu with a lot of locations (let say a depth of 3 in the tree), we need to add the complete list of location id ?

Is there a mechanism comparable with the legacy "smart cache clear" to clear for example all folders when an article is edited ?  

Thanks !

Sunday 10 February 2013 9:23:40 pm

Afaik there is no equivalent (yet) of the smart-view-cache logic.

But since we have implemented the PURGE requests, maybe hooking in logic which emulates the old cache-blocks and smartviewcache is not too hard.

You could f.e. create "virtual cache location" with ids like "cacheblock_xx", and via the signalslot system implement the code which checks which of those locations have to be expired, given the current action

Monday 11 February 2013 10:10:51 am

Matthieu : Sorry to have lead you in a wrong way... This is the syntax for cache PURGE :-s...

Quote from Gaetano Giunta :

Afaik there is no equivalent (yet) of the smart-view-cache logic

Actually the smart view cache IS handled, but from the legacy stack. Everything should work as expected when clearing the cache / publishing content. However the settings are still to be configured in legacy.

Tuesday 12 February 2013 9:53:45 pm

Thank you for our anwsers ! 

I'm trying to implement what you suggest Gaetano with signal slot the documentation is a litlle light here : https://confluence.ez.no/display/EZP/Signal-Slot

I have no clue how to achieve this steps : 

  1. Make the Slot available through the Symfony service container as a service
  2. Register the Slot to react to the Signal of type eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal

I have seen some clue in papi.yml but I'm not sure ...

I have also seen that there is issues opened in Jira because it's not exposed as a service. 

 

Is it to early to try to implement a slot ?

Thank !

Tuesday 05 November 2013 11:27:53 am

Hi,

I have the exact same problem here (invalidate a subrequest when any of its associated locations is published).

In the end, is there any solution working ?

Modified on Tuesday 05 November 2013 11:29:35 am by Benjamin Choquet

Tuesday 28 January 2014 4:51:28 pm

BTW, I just tested using 5.2 version (not using a subrequest but a custom controller), and as Jerome suggested, this can be made to work extra-easily via smartviewcache. It even works out of the box with the settings coming from the DemoBundle!

- in your custom controllers responses, set caching headers and add an 'X-Location-Id' header with id of root node of the menu. Add a timestamp in the output html for easy debugging

- in viewcache.ini, set up expiration rules, so that when a menu item is changed, the root node is expired as well

- enable Sf gateway-cache by putting in your index_xxx.php: putenv( "USE_HTTP_CACHE=true" );

- test it: load controller, twice check timestamp and http headers; edit grandchild node of menu root, check again

Modified on Tuesday 28 January 2014 4:52:22 pm by Gaetano Giunta

Wednesday 14 May 2014 2:42:10 pm

Hi there,

we have the same problem in a project. Wouldn't the recommended Varnish config conflict with the fact of using HTTP_CACHE? As it is mentioned here: https://confluence.ez.no/display/EZP52/Using+Varnish that "In order to use Varnish, you need to deactivate it by commenting the line where EzPublishCache is instantiated"?

Best,

Till

Wednesday 14 May 2014 4:23:25 pm

Quote from Till Kubelke :

Hi there,

we have the same problem in a project. Wouldn't the recommended Varnish config conflict with the fact of using HTTP_CACHE? As it is mentioned here: https://confluence.ez.no/display/EZP52/Using+Varnish that "In order to use Varnish, you need to deactivate it by commenting the line where EzPublishCache is instantiated"?

Best,

Till

Hi Till,

We have it working with eZ Publish 5.2 as Gaetano describes it. That USE_HTTP_CACHE setting turns off Symfony's built in reverse proxy, but it is the ezpublish.yml settings mentioned at the bottom of that documentation page that connect eZ Publish to Varnish.  Another note is that you have to make sure to turn on view caching in the eZ Publish legacy stack.

Friday 05 February 2016 11:20:44 am

Quote from Gaetano Giunta :

BTW, I just tested using 5.2 version (not using a subrequest but a custom controller), and as Jerome suggested, this can be made to work extra-easily via smartviewcache. It even works out of the box with the settings coming from the DemoBundle!

- in your custom controllers responses, set caching headers and add an 'X-Location-Id' header with id of root node of the menu. Add a timestamp in the output html for easy debugging

- in viewcache.ini, set up expiration rules, so that when a menu item is changed, the root node is expired as well

- enable Sf gateway-cache by putting in your index_xxx.php: putenv( "USE_HTTP_CACHE=true" );

- test it: load controller, twice check timestamp and http headers; edit grandchild node of menu root, check again

I'm writing native code where there is no legacy; so no viewcache.ini. Is there any way we can achieve the goal? I'm using 5.4.5.

 

Thank you very much,

Rashidul

Thursday 11 February 2016 12:59:12 pm

Which goal? "viewcache.ini"? If so: https://doc.ez.no/display/TECHDOC/Smart+HTTP+cache+clearing

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from