Clear dispatcher cache when resource only exist in AEM Dispatcher | Community
Skip to main content
Rohit_Utreja
Community Advisor
Community Advisor
July 7, 2023

Clear dispatcher cache when resource only exist in AEM Dispatcher

  • July 7, 2023
  • 5 replies
  • 3395 views

We have a scenario where we have some dynamic page. These pages have been handled by AEM dispatcher( and getting cached in AEM dispatcher. These pages do not exist in AEM instance.

As a next step, we have to clear the cache for these pages using replication API. The page URL contains a selector in the URL, e.g. /content/abc/xyz/test.sample.html

 

We have written code for the same and we could see below error.

*WARN* [sling-default-2] com.adobe.cq.cloudconfig.core.impl.ConfigurationReplicationEventHandler Resource [/content/abc/xyz/test.sample.html] not found for ReplicationAction

 

Since the resource do not exist, we are getting this error.

 

How to clear cache for these pages using replication API when these page do not exist in AEM instance but do exist in the dispatcher?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

aanchal-sikka
Community Advisor
Community Advisor
July 7, 2023

@rohit_utreja 

 

How about using TTL on these pages. Then they would be flushed periodically.

Aanchal Sikka
Rohit_Utreja
Community Advisor
Community Advisor
July 7, 2023

@aanchal-sikka 

Yes, that is an option but it is not aligned with the use case.

we have to clear the cache with selector in the URL. URLs can be as follows.

/content/abc/xyz/test.sample1.html

/content/abc/xyz/test.sample2.html

/content/abc/xyz/test.sample3.html

 

Now, all of these page cache need to be cleared only when there are some changes in the content. We will get to know about these content changes from an API.
Hence, if we use TTL, it will be applicable to all URLs, not to a specific URL.

 

To conclude this, we can't use TTL.

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
July 7, 2023

I think you can try some of below options:

[1]. You can use a CURL command to flush the specific resource, something like this:

 

curl -H “CQ-Action: Flush” -H “CQ-Handle: /content/my/page/path” -H “CQ-Path:/content/my/page/path” -H “Content-Length: 0″ -H “Content-Type: application/octet-stream”

 

[2]. You can create a custom servlet to flush the cache, something like this: https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/page-invalidate.html?lang=en#example-flush-servlet

[3]. You can manually delete the entry from the dispatcher server, (you could wrap this into a script and invoked from somewhere else) something like this:

 

#the path where the cache is stored rm -rf /mnt/var/html/www/content/my/page/path

 

 

Esteban Bustamante
Rohit_Utreja
Community Advisor
Community Advisor
July 7, 2023

We have tried this.
Since the resource,/content/abc/xyz/test.sample.html doesn't exist, we get the warning com.adobe.cq.cloudconfig.core.impl.ConfigurationReplicationEventHandler Resource [/content/abc/xyz/test.sample.html] not found for ReplicationAction.

 

Page cache has not been cleared and we are still getting the old copy. 

Rohit_Utreja
Community Advisor
Community Advisor
July 7, 2023

The problem is that the replication API is meant to work with a resource, if you don't have a resource you cannot use this API. You should explore my 3rd option in that case.


Since it is a AEMaaCS, we can't do that as well.
is there any other option for this?

Sudheer_Sundalam
Community Advisor
Community Advisor
July 7, 2023

@rohit_utreja 

 

Try using the ACS Commons Dispatcher Flush rules in the lower environment to see if it works in your usecase:

https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-rules/index.html

I would setup a flush rule as follows and try:

/content/abc/xyz/test(.*) = /content/abc/xyz/test

Rohit_Utreja
Community Advisor
Community Advisor
July 7, 2023

ACS commons dispatcher flush is not compatible with AEMaaCS, hence can't use this.

joerghoh
Adobe Employee
Adobe Employee
July 7, 2023

What do you mean with "these pages do not exist in AEM"? How do you get them created then?

Rohit_Utreja
Community Advisor
Community Advisor
July 10, 2023

We are using dispatcher rewrite rules for convert a url into selector based url.
for example, end user is accessing the url https://www.abc.com/sample/, 
dispatcher is redirecting it to /content/abc/xyz/test.sample.html

Now, the cache has been created under root with path /content/abc/xyz/test.sample.html

We are performing certain operations based on the selector in the URL.

Now, the question is, how to clear the cache of these pages based on the selector (these selector are changing as well)?

joerghoh
Adobe Employee
Adobe Employee
July 20, 2023

Then it depends how your content structure looks like.

 

Assuming that  www.abc.com/sample is rewritten into /content/abc/xyz/test.sample.html, then I hope that you have a path /content/abc/xyz/test in your repository; everything else would make this situation much more complex.

 

So in that case invalidating that path should be sufficient. But if you have more pages like this and rewrite /sample1 to /sample100 the same way, they will be invalidated as well.

But there is no way around that.

 

 

DPrakashRaj
Community Advisor
Community Advisor
July 7, 2023

All the selector pages should flush automatically with publishing of main page. You might check the 

/statfileslevel and 

 /invalidate

section of your dispatcher configuration which works for doing the auto invalidation of the resource if certain node is activated/deactivated.

 

check this blog.  
https://www.axamit.com/blog/adobe/dispatcher-4#:~:text=You%20may%20use%20the%20%2Fstatfileslevel,to%20the%20level%20you%20specify.