Tuesday, June 21, 2016

Dispatcher Cache Invalidation for Multi Site Configuration - Adobe CQ5(AEM)

Dispatcher Cache Invalidation for Multi Site Configuration - Adobe CQ5(AEM)

This post will explain the approach to invalidate the cache for particular site in multi site configuration - Adobe CQ5(AEM).

Recently, i was working on a dispatcher caching issue with multi site configuration - The cache was not getting invalidated in all the dispatcher.

The setup is with multiple dispatcher connected via load balancer. The load balancer will route the request to individual dispatchers via round robin algorithm. The dispatcher is configured with individual virtual host and farm for every site(Load balanced DNS is used).

The flush agent was configured in publisher for every site with load balanced DNS(the flush agent was equal to number of sites configured in dispatcher) - The issue here is when ever publisher send the invalidation request that is not reaching the corresponding dispatcher as the flush agent is configured with load balanced DNS for invalidation URI - The request will be send to random dispatcher from the load balancer due to this the cache will not be invalidated in all the dispatcher.

Solution:

Create a flush agent in individual publisher that points to individual dispatcher(based on the renders configuration). The flush agent should be configured with dispatchers server name(one flush agent in one publisher)

http://dispatcher1.server.name:80/dispatcher/invalidate.cache



Make sure the following HTTP Headers are configured.


The flush agent can be configured in author also, if we are configuring in author then the number of flush agents should be equal to number of dispatchers.

Create a Location Match in all the dispatchers httpd.con file for all the websites:

<LocationMatch "^/dispatcher/invalidate.cache$">
 
    # Site Finance
    SetEnvIfNoCase CQ-Path ".*/content/sample1/.*" FLUSH_HOST=sample1.com
    RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST

    # Site TR
    SetEnvIfNoCase CQ-Path ".*/content/sample2/.*" FLUSH_HOST=sample2.com
    RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST
</LocationMatch>

Based on the CQ-Path the corresponding sites cache will be invalidated.

Referred from  - http://www.netcentric.biz/blog/2016/01/aem-dispatcher-cache-invalidation-for-multiple-dispatcher-farms.html


3 comments:

  1. Hi Albin,

    In addition to the above steps, please increase the stat file level to maximum depth of pages/assets-1, for each of the farms corresponding to each of the domain.

    Thanks.
    Sumanth

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi, I am having 2 virualhosts,

    1) http://abc.com
    2) http://xyz.com

    I am having only one dispatcher flush agent which is using IP address . Please see below the uri

    http:/xx.xx.xx.xx:80/dispatcher/invalidate.cache.

    Please see below my httpd.conf file entry


    # domain A
    SetEnvIf CQ-Path “.*/abc/.*" FLUSH_HOST=abc.com
    RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST
    # domain B
    SetEnvIf CQ-Path “.*/xyz/.*" FLUSH_HOST=xyz.com
    RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST



    The issue is , when i try to replicate the page in xyz.com , The first virtualhost ( abc.com always getting refreshed) by the dispatcher flush agent . can you please let me know i am missing any configuration.


    Thanks
    Sam

    ReplyDelete