Hello Techies,
I am making a series of calls from graphql (which is placed outside AEM, consider it as 3rd party) via Dispatcher to my publish instance like
http://my-publish-domain/api/assets/my/content_fragment/path.json.
I could get the result as json, but this response is not getting cached in dispatcher docroot.
On a deeper look i could see in dispatcher logs says like below and these json results are never cached.
Backend forbids caching, sent: 'Pragma: no-cache'
Further the publish instance directly (not through dispatcher) itself give following Response header.
Not sure this is causing the issue of not caching in dispatcher.
My Query
Can it be customised so that we can cache the .json result, because every-time when a page is refreshed always the Asset API calls reaches the origin server?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @babusankar : Sorry by mistake I pressed the button me too. I am not having this issue.
It Pragma header will be causing this issue. You can raise this issue with Adobe but as a workaround, you can create a Java Servlet filter and put conditions for the asset API remove this Pragma header once the response is ready to send from publisher to webserver (for reference: https://www.codejava.net/java-ee/servlet/how-to-create-java-servlet-filter)
Hoping it will be of some use for you
Hi @babusankar : Sorry by mistake I pressed the button me too. I am not having this issue.
It Pragma header will be causing this issue. You can raise this issue with Adobe but as a workaround, you can create a Java Servlet filter and put conditions for the asset API remove this Pragma header once the response is ready to send from publisher to webserver (for reference: https://www.codejava.net/java-ee/servlet/how-to-create-java-servlet-filter)
Hoping it will be of some use for you
Hi @brijesht7477132 ,
Firstly thank you for your time on this and reply.
I implemented a Java Servlet Filters with /api/assets pattern and was able to capture the request & response objects.
However what i observed are
My rough guess is that the Java Servlet Filter (first candidate) is trying to set the response header, which are again rewritten by the AEM OOTB Servlet/Filter/Service (last candidate) that corresponds to /api/assets API before handing over to dispatcher.
So the flow is like
Client(Browser) --> Dispatcher --> Java Servlet Filter --> AEM OOTB Servlet/Filter/Service
which finally lands to the same situation.
Attaching capture of code and dispatcher logs for better clarity
Hi @babusankar ,
Here is the catch you have to update pragna header after the filterChain.doFilter(); method.
Meaning you are updating the header after the request is process.
Th flow should be Client(Browser) --> Dispatcher --> Java Servlet Filter --> AEM OOTB Servlet/Filter/Service --> Java Servlet Filter --> Dispatcher --> Client(Browser)
Hoping this will solve your problem
I was having the scope of the Sling Servlet as REQUEST but it should be FORWARD to get the headers working.
Thanks for all the efforts. Closing the ticket
Hi @babusankar I tried the same solution and using author to test but its not working for me. It always returns both header in response with no-cache.
@Component
@SlingServletFilter(scope = {SlingServletFilterScope.FORWARD}, extensions = { "json" }, methods = {
"GET", "HEAD" }, pattern = "/api/assets/.*")
public class AssetApiFilter implements Filter
Could you please share if there is any additional configuration you did to make it work ?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies