Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to recursively flush directories in the CQ5/AEM apache dispatcher?

Tags:

dispatcher

aem

I have a dispatcher set up with a fairly deep stats file level due to a particular project in a multi tenancy situation.

What I'm hoping is for a way to be able to recursively flush directories to mimic a more shallow stats file level for the other tenants.

Is there a dispatcher flush command that allows me to explicitly delete a directory of content?

like image 245
Bayani Portier Avatar asked Jul 25 '14 01:07

Bayani Portier


People also ask

How do I clear the dispatcher cache in AEM?

To invalidate (or flush) the Dispatcher cache without activating a page, you can issue an HTTP request to the dispatcher. For example, you can create an AEM application that enables administrators or other applications to flush the cache. The HTTP request causes Dispatcher to delete specific files from the cache.

Which type of replication agent do you create to flush the web server cache for a newly activated page?

Which type of Replication Agent do you create to flush the Web server cache for a newly activated page? Create a Dispatcher Flush Agent.

How should a developer configure the replication agent to flush the dispatcher cache for newly activated?

How should a developer configure the replication agent to flush the dispatcher cache for a newly activated page? A. Set the serialization type property of the default agent to dispatcher flush.

Which configuration section should be used to resolve the domain name by dispatcher?

The domain name system resolves the domain names to the IP address of the web server. The Dispatcher cache mirrors the directory structure of the AEM content repository. The file paths below the document root of the web server are the same as the paths of the files in the repository.


1 Answers

You could achieve this yourself by sending a simple GET request to your dispatcher. The path on the Dispatcher that you need to hit is /dispatcher/invalidate.cache.

The following headers ensure that it's processed correctly:

  • CQ-Action: This can be set to "DELETE" to remove the content. I think "EXPIRE" also works to flag the content as out-of-date, but not remove it physically from the cache.
  • CQ-Handle: This specifies what should be deleted, starting from the root of your cache folder. E.g. "/content/geometrixx", would remove geometrixx and everything under it. "/" would remove everything in the cache.
  • Content-Length & Content-Type: Ensure that the request is handled correctly. As we're not sending a body, the length can be set to 0. Content-Type can be "application/octet-stream" (haven't tried other values).

The final curl command that you would build would then look something like:

curl -v \
-H "CQ-Action: DELETE" \
-H "CQ-Handle:/" \
-H "Content-Length: 0" \
-H "Content-Type: application/octet-stream" \
http://localhost:80/dispatcher/invalidate.cache;

(Where this is removing everything from the cache on a Dispatcher running under localhost on port 80. This backslashes here are optional, just making it easier to read)


You could issue this GET request from any box (subject to your firewall restrictions, etc.), for example, it could come from:

  • your CI build agent
  • a scheduled job in your Publish instance
  • an admin component in your Author instance that takes a given path to flush.
like image 62
anotherdave Avatar answered Oct 21 '22 06:10

anotherdave