Expand my Community achievements bar.

SOLVED

Aem Author Dispatcher - Delete all cache

Avatar

Level 4

Good morning,

on Aem Author I have a web portal with the following structure:

 

- my-project
- my-project/en
- my-project/en/page1
- my-project/en/page1/sub-page1
- my-project/en/page2
- my-project/en/page2/sub-page2

 

how can I remove the cache from the Author Dispatcher of the whole "web portal" and of the "clientlibs" by calling the "dispatcher / invalidate.cache" interface with the command "curl" ?

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

You can use the below command to clear the dispatcher cache.

Entire Cache :the easiest way to invalidate the dispatcher cache would be to execute a command like this on the system where the dispatcher runs:

$ find . -name ".stat" -exec touch {} \;

This touches every stat file and marks the files as invalid.

 

Flush Dispatcher Cache for Specific Path:
curl -H “CQ-Action: Flush” -H “CQ-Handle: /content/geometrixx/en/products” -H “CQ-Path:/content/geometrixx/en/products” -H “Content-Length: 0″ -H “Content-Type: application/octet-stream” http://dispatcher-server-hostname:port/dispatcher/invalidate.cache

 

Thanks

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi,

 

You can use the below command to clear the dispatcher cache.

Entire Cache :the easiest way to invalidate the dispatcher cache would be to execute a command like this on the system where the dispatcher runs:

$ find . -name ".stat" -exec touch {} \;

This touches every stat file and marks the files as invalid.

 

Flush Dispatcher Cache for Specific Path:
curl -H “CQ-Action: Flush” -H “CQ-Handle: /content/geometrixx/en/products” -H “CQ-Path:/content/geometrixx/en/products” -H “Content-Length: 0″ -H “Content-Type: application/octet-stream” http://dispatcher-server-hostname:port/dispatcher/invalidate.cache

 

Thanks

Avatar

Employee Advisor

Hi ,

 

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. Optionally, the Dispatcher then refreshes the cache with a new copy.

Delete cached files

Issue an HTTP request that causes Dispatcher to delete files from the cache. Dispatcher caches the files again only when it receives a client request for the page. Deleting cached files ins this manner is appropriate for web sites that are not likely to receive simultaneous requests for the same page.

 

Dispatcher flushes (deletes) the cached files and folders that have names that match the value of the CQ-Handler header. For example, a CQ-Handle of /content/geomtrixx-outdoors/en matches the following items:

  • All files (of any file extension) named en in the geometrixx-outdoors directory

  • Any directory named " _jcr_content" below the en directory (which, if it exists, contains cached renderings of sub-nodes of the page)

All other files in the dispatcher cache (or up to a particular level, depending on the /statfileslevel setting) are invalidated by touching the .stat file. This file’s last modification date is compared to the last modification date of a cached document and the document is re-fetched if the .stat file is newer.

Invalidation (i.e. touching of .stat files) can be prevented by sending an additional Header CQ-Action-Scope: ResourceOnly. This can be used to flush particular resources without invalidating other parts of the cache, like JSON data that is dynamically created and requires regular flushing independent of the cache (e.g. representing data that is obtained from a third-party system to display news, stock tickers, etc.).