Hi @knan ,
You can achieve this in multiple ways:
The /rules property controls which documents are cached according to the document path. Regardless of the /rules property, Dispatcher never caches a document in the following circumstances:
Request URI contains a question mark (?).
- Indicates a dynamic page, such as a search result that does not need to be cached.
The file extension is missing.
- The web server needs the extension to determine the document type (the MIME-type).
The authentication header is set (configurable).
If the AEM instance responds with the following headers:
- no-cache
- no-store
- must-revalidate
If you want handle this through AEM backend then below are the 2 options.
1. At component level component model class.
@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class Component{
@Inject
private SlingHttpServletResponse response;
@PostConstruct
protected void init() {
response.setHeader("Dispatcher", "no-cache");
}
}
2. At page level, now you can call this page in body html based on some condition:
@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class PageMOdel {
@Inject
private SlingHttpServletResponse response;
@PostConstruct
protected void init() {
response.setHeader("Dispatcher", "no-cache");
}
}
Thanks
Tarun