Dispatcher flush for multiple sites with different content structure
Lets assume I have 3 sites with different content structure each:
SiteA
Servername sitea.example.com
/content/sitea/
Has statfileslevel 4
SiteB
Servername siteb.example.com
/content/siteb/
Has statfileslevel 3
SiteC
Servername sitec.example.com
/content/sitec/
Has statfileslevel 2
Lets also assume that all sites share some DAM assets and share design/layout assets (in /etc.clientlibs/*) so I want to use a common shared dispatcher cache folder for all sites.
Now I have one *.vhost file per site, with the respective Servername. Reason being that I need different RewriteRules to map incoming requests to full content paths (that are externalized in markup based on /etc/hosts config, which differs due to different content structure).
Now I have one additional flush.vhost file, which has
ServerName "localhost"
ServerAlias "\*.local" "127.0.0.1" "*.adobeaemcloud.net" "*.adobeaemcloud.com" "flush"
this gets all the dispatcher flush requests as well as internal Adobe requests etc - it has no site-specific rewrite rules in order to not mess up the Adobe system HTTP requests
So far so good.
Now all requests (regardless of vhost) are handed over to the dispatcher-handler, this is where the dispatcher farm configurations come into play.
Each site has a farm config, and the farm has a list of hostnames in the /virtualhosts section which determines the farm that gets to handle the request.
Assume the /cache and /invalidate sections are different for every farm/site (due to content structure and statfileslevels, see above).
Now I want to send the dispatcher POST /dispatcher/invalidate.cache requests matching to each farm, so it gets handled properly.
Meaning flush requests for specific content payload (CQ-Path HTTP header), need to go to the right farm:
for /content/sitea/ it should go to a.farm
for /content/siteb/ it should go to b.farm
for /content/sitec/ it should go to c.farm
But the HTTP Host header in the POST flush request is "flush" (or is it actually something different? not documented anywhere)
In order to make the flush request go to the matching farm, I have to match the host name.
I cannot use a single generic flush farm because rules inside the farm file cannot be conditional, and requirements are different.
How can the above be achieved in AEM cloud?
Note: I tried modifying the HTTP Host header in the flush.vhost - e.g. before the request hits the dispatcher-handler
<LocationMatch "^/dispatcher/invalidate\.cache$">
SetEnvIfNoCase CQ-Path ".*/sitea/.*" FLUSH_HOST=sitea
RequestHeader set Host "sitea.example.com" "expr=%{env:FLUSH_HOST} == 'sitea'"
</LocationMatch>
But this does not work, I am not seeing flush requests hitting “a.farm”
I assume the “CQ-Path” HTTP header is missing or has a different name?Due to the log file LogFormat restrictions in the cloud, it’s impossible to debug this formally