问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/24946526/is-it-possible-to-recursively-flush-directories-in-the-cq5-aem-apache-dispatcher