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

北城余情 提交于 2019-12-04 05:03:58

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.

It's not clear to me the overall picture but IIRC dispatcher flush if flush the entire directory and all of it's subdirectories. The file types that will be flushed depends on your dispatcher configuration.

So if you flush /content/geometrixx the whole site will be flushed. (Please someone correct me if I remember wrongly).

The easiest way to do it is IMHO to re-activate the page that works as root of the area you want to flush. Otherwise you could even develop your own sling servlet that sends appropriate headers to dispatcher

http://docs.adobe.com/docs/en/aem/6-0/deploy/configuring/replication.html#Extended

Other options that always works are the same as the HTTP headers but sent with curl commands or OS processes that deletes the directory from the file system.

I'm not saying the last two are the best as there could be side effects; but they should do the job as well.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!