@component(immediate = true, service = Servlet.class, property={
"sling.servlet.methods=" + "GET",
"sling.servlet.resourceTypes=" + "sling/servlet/default",
"sling.servlet.extensions=" + "abc"
})
public class abcServlet extends SlingAllMethodsServlet {
}
we have above default servlet with extension.
we dont want to cache the response from API when this is triggered.
we are trying to add this rule in dispatcher rules.any file.
# Rule. Don't cache API requests
/0030 {
/glob "/*.abc.html"
/type "deny"
}
will this be sufficient or do we have any alternate way to do this job?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
@sudarshanreddy if u are looking for alternative way other than dispatcher try setting below response header to your servlet
response.setHeader("Dispatcher", "no-cache");
@Inject
private SlingHttpServletResponse response;
@PostConstruct
protected void init() {
response.setHeader("Dispatcher", "no-cache");
}
Please follow below URL for more details
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-cache-pages-with-se...
/0405 { /glob "*.print.html/*" /type "deny" }
print is selector here
Im looking for alternative way to do?
@sudarshanreddy if u are looking for alternative way other than dispatcher try setting below response header to your servlet
response.setHeader("Dispatcher", "no-cache");
@Inject
private SlingHttpServletResponse response;
@PostConstruct
protected void init() {
response.setHeader("Dispatcher", "no-cache");
}
Below is the best suggested approach by @Jagadeesh_Prakash
Hi @sudarshanreddy Inside URL params. Try below code
/ignoreUrlParams
{
#/0001 { /glob "*" /type "deny" }
/0002 { /glob "abc" /type "deny" }
}
Hi @sudarshanreddy
Use abc selector to register the Servlet and deny all url from that selector.
Hi @sudarshanreddy ,
You can set response header in your servlet that will prevent it to be cached.
Something like below:
response.setHeader("Dispatcher", "no-cache");
Thanks
Tarun
Views
Likes
Replies