How to flush the dispatcher cache when there are farms with separate cache folders

When I have multiple virtual hosts with separate AEM Dispatcher cache farms configured in my web server, then how do I flush the correct cache from AEM?

Environment

Apache HTTP Server / AEM dispatcher

Steps

Set up one dispatcher flush agent per dispatcher farm, set the Host header and configure the "Agent user ID" with a user that has read access to relevant paths.

In the solutions below we assume the following:

  • You are using Apache HTTP Server 2.2 or later version
  • Multiple VirtualHosts configured
  • Multiple dispatcher farms with separate caches

For example:
Apache httpd VirtualHost configurations:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.geometrixx.com
    ServerAlias *.geometrixx.com
    DocumentRoot /var/www/html/cache-www-geometrixx-com
     ...  
</VirtualHost>

<VirtualHost *:80>
    ServerName www.geometrixx-outdoors.com
    ServerAlias *.geometrixx-outdoors.com
    DocumentRoot <Global Doc root>/site2
    Include <Configurations specific to site2>
</VirtualHost>
DocumentRoot /var/www/html/cache-www-geometrixx-outdoors-com

In the dispatcher configuration, you have multiple farms configured to handle different sites by host name (virtualhosts):

/virtualhosts
  {
      "*geometrixx.com*"
  }

  /renders
  {
        ...
  }

  /cache {
       /docroot "/var/www/html/cache-www-geometrixx-com"

Set up multiple flush agents

If you only have a handful of separate dispatcher farms (5 or less), then configuring multiple flush agents is an easy solution.

  1. Open http://aem-host:port/miscadmin for each AEM publish instance

  2. Browse to Replication => Agents on Publish

  3. Click Edit

  4. Under the Agent user ID, enter the name for a user which you create later that would be associated with this agent.  You could use a naming convention with the host name of the site.  For example: "flush-agent-www-geometrixx-com" 

  5. Select the "Extended" tab

  6. Under HTTP Headers add another header.  As the value enter "Host: www.geometrixx.com" where "www.geometrixx.com" should be replaced by one of the sites' DNS hosts.

  7. Click Ok to save

  8. Go to http://aem-host:port/useradmin and create the user from step 4

  9. On the Permissions tab of the user, grant the user read access to any paths that you would like the agent to be allowed to flush for the referenced site.  For example: /content/geometrixx,  /content/dam, /etc, /libs, /apps, /var

  10. Save

  11. Repeat steps 1 - 10 for all other sites on each publish instance.  You will be creating one flush agent for each site on each publish instance.

  12. On the web server, share common paths using symlinks.  For example, you could set symlinks for /content/dam, /etc, /libs, /apps, and /var to a common cache location.  Then /content and anything under the root of the cache would be separately cached.  Here's an example command for the /libs folder 

    ln -s /var/www/html/cache-www-geometrixx-com/libs /var/www/html/shared-cache

  13. Now when you activate pages under a specific site, the flush request would only get directed to the applicable flush agent

Adobe 標誌

登入您的帳戶