Invalidate cache servlet | Community
Skip to main content
February 23, 2023
Solved

Invalidate cache servlet

  • February 23, 2023
  • 2 replies
  • 916 views

I am trying to write a servlet to invalidate cache and the code is not working as the distribution request is not working

 

@Reference
private Distributor distributor;

ResourceResolver resolver = ...; // the resource resolver used for authorizing the request
String agentName = "publish";    // the name of the agent used to distribute the request

String pathToInvalidate = "/content/to/invalidate";
DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.INVALIDATE, false, pathToInvalidate);
distributor.distribute(agentName, resolver, distributionRequest);

This is the reference code I am working on  

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

@kaartikn Please share the Stacktrace for troubleshooting. Hopefully you are not testing it locally, but on a AEMaaCS Environment.

Whole process is defined in below link:

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/content-delivery/caching.html#explicit-invalidation:~:text=further%20downstream%20actions.-,Sling%20Content%20Distribution%20(SCD),-NOTE

 

This should help

 

2 replies

Umesh_Thakur
Community Advisor
Community Advisor
February 24, 2023

if possible pass the stack trace

krati_garg
Adobe Employee
krati_gargAdobe EmployeeAccepted solution
Adobe Employee
February 26, 2023

@kaartikn Please share the Stacktrace for troubleshooting. Hopefully you are not testing it locally, but on a AEMaaCS Environment.

Whole process is defined in below link:

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/content-delivery/caching.html#explicit-invalidation:~:text=further%20downstream%20actions.-,Sling%20Content%20Distribution%20(SCD),-NOTE

 

This should help

 

DmytroPanchenk
September 21, 2023

I am trying to do the same on the RDE in a Sandbox program, and it doesn't work.

There is no stacktrace.

The publish server receives the request and issues the one for the dispatcher (see the zipped log attached). The dispatcher receives the request, but still returns the cached content until the "max-age" expires (see the screenshot attached for the cached and non-cached output).