Dispatcher Flush Rules
Available since version 1.2.0
Define simple, yet powerful, rules for targetted flushing of files cached by Dispatcher.
Dispatcher cache flushing is typically done by setting a stat level, which means a piece of content changes at a certain “folder level” in the cache, then everything under that folder (or a relative folder level) is invalidated. Ideally, dispatcher cache invalidation is as specific as possible, so items in the cache live their longest possible life, however creating general stat level rules to achieve this can be tricky.
For example, if a website section
/content/my-site/us/en/products leverages images from
/content/dam/products, anytime an image asset in
/content/dam/products is updated, we want to ensure any uses of it by web pages in
/content/my-site/us/en/products are also updated. We could set a stat level of 1 that invalidates everything under
/content when anything under
/content changes, however this inefficient, since an update to
/content/my-site/us/en/products would invalidate everything under the rest of the web site too, for example:
Instead we can use Dispatcher Flush rules to create a “smart” flush scheme, that listens for replications to
/content/dam/products and then invalidates ONLY
/content/my-site/us/en/products, leaving the rest of the web site’s content safely cached.
How to Use
Dispatcher Flush Rules are intended to be deployed and executed on AEM Publish, which should have On Trigger Flush Agents set up. Running Dispatcher Flush Rules on AEM Author that flush Dispatchers for AEM Publish can result in race-conditions, where the Dispatcher cache invalidation (and re-caching of content) can occur prior to the new replicated content being persisted on AEM Publish. See the “Flushing from AEM 5.6+ Publish Servers” section below for how to set up On Trigger Flush Agents.
Create a new
sling:OsgiConfig node for each logical flush rule set. A good practice is to create a “global” configuration and separate configurations per “site”.
OSGi Config Properties
Defines the ReplicationActionType to use when issuing the chained replications.
INHERIT: Use the action type of the origin replication
ACTIVATE: Invalidates the cached files opposed to deleting
DELETE: Deletes the cached files opposed to invalidating
Defines the flush mappings in the format (the delimiter is
Introduced in 1.5.0, regex groups can be used to further dynamic behavior.
To flush all pages under
/content/mysite when an new DAM
jpg is replicated use
prop.rules.hierarchical=[ "/content/dam/.*\.(png|jpg)=/content/mysite" ]
or using the new regex grouping (v1.5.0) to flush site pages based on activations to corresponding site dam folders
prop.rules.hierarchical=[ "/content/dam/([^/]+)/.*\.(png|jpg)=/content/$1" ]
In this case the following activations would triggers the follow flushes:
`/content/dam/mysite/animals/dog.jpg` would flush `/content/mysite` `/content/dam/yoursite/animals/cat.jpg` would flush `/content/yoursite`
Defines the flush mappings in the (same as hierarchical) format
used to initiate “ResourceOnly” dispatcher flush requests.
**Note: To use ResourceOnly mappings, a second set of Dispatcher Flush Agents must be created with the exact HTTP Header
CQ-Action-Scope: ResourceOnly. **
These Flush Agents should also be configured as
One-to-Many Patterns-to-Flush Paths (Available in v1.9.2+)
Added in 1.9.2 (not 1.9.0), multiple flush paths can be assigned to a replication pattern. Each absolute path to flush is delimited by
Flushing from AEM 5.6+ Publish Servers
Dispatcher Flush Rules work from AEM 5.6 Publish Servers as well. Simple configure your Dispatcher Flush Agents on Publish to issue “On Trigger”. (It is likely this has been previously configured if you are already using Publish-side flushing).
Global Config Example
Delete the entire cache when a new package is activated.
On AEM 6.2 or above, this service uses a Service User for repository access. This user is configured with the expected permissions required, but additional permissions may be required if your repository design deviates from the expected structure.