April 28, 2020
Estimated Post Reading Time ~

Flush the dispatcher cache for DAM assets used on multiple websites(Domains) through ACS AEM Commons - Dispatcher Flush Rules

In some cases, the same DAM asset is used on multiple websites(Domains) and the individual websites caches the assets locally, the regular replication agent configuration will not clear the cache for all the websites that use the common DAM asset.

This post will explain the approach to flush the dispatcher cache for common DAM assets used om multiple websites through ACS AEM Commons - Dispatcher Flush Rules - Adobe Experience Manager(AEM).

Install acs-aem-commons-content-3.9.0.zip package(ignore if it is already available):

ACS commons package download link:
https://github.com/Adobe-Consulting-Services/acs-aem-commons/releases/tag/acs-aem-commons-3.9.0

Configure the ResourceOnly Flush agent in publisher:
Create the Flush agent in publisher with following configuration





Configure the Dispatcher IP address in the URL





Configure Dispatcher Flush Rules in publisher:
Login to Adobe Experience Manager Web Console Configuration - http://localhost:4502/system/console/configMgr

Add New configurations under “ACS AEM Commons - Dispatcher Flush Rules” with below properties

Replication Action Type = Invalidate Cache
Flush Rules (ResourceOnly) = /content/dam/(.*)=/dam-sitea/content/dam/$1&/dam-siteb/content/dam/$1&/dam-sitec/content/dam/$1


Enable the configureation for all the sites.Prefix the DAM path with unique name for every site e.g dam-sitea, dam-siteb, this prefix path will be used in dispatcher configuration to identify the Host header.

Configure Dispatcher:
Configure the below mentioned LocationMatch configuration in httpd.conf file(the configuration can be kept in a different file and included into httpd.conf file for better management)

<LocationMatch "^/dispatcher/invalidate.cache$">

# DAM Flush - Site TR
SetEnvIfNoCase CQ-Path "/dam-sitea/.*" FLUSH_HOST=example-sitea.com
RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST

# DAM Flush - Site Finance
SetEnvIfNoCase CQ-Path "/dam-siteb/.*" FLUSH_HOST=example-siteb.com
RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST

# DAM Flush - Site Arg
SetEnvIfNoCase CQ-Path "/dam-sitec/.*" FLUSH_HOST=example-sitec.com
RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST

#Additional site configuration

#This two lines should be below all the DAM Flush configurations
RequestHeader edit CQ-Path "^/dam-([^/]+)/" "/"
RequestHeader edit CQ-Handle "^/dam-([^/]+)/" "/"

#Configurations for content below

</LocationMatch>

Configure the CQ-path with the prefix defined in Dispatcher Flush Rules and configure the hostname of the corresponding site in the FLUSH_HOST

Whenever new sites are getting added - Configure the new site in Dispatcher Flush Rules and dispatcher LocationMatch configuration

After enabling this configuration, whenever the common assets are activated the local cache for all the website will be flushed - Only the activated resource will be invalidated as the ResourceOnly configuration is enabled in agent configuration, the .stat file will not be touched.


By aem4beginner

No comments:

Post a Comment

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