April 27, 2020
Estimated Post Reading Time ~

Dispatcher Cache Invalidation for Multi Site Configuration

This post will explain the approach to invalidate the cache for a 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 dispatchers connected via a load balancer. The load balancer will route the request to individual dispatchers via a 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 a number of sites configured in dispatcher) - The issue here is whenever publisher sends 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 sent 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


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.