Expand my Community achievements bar.

SOLVED

Caching response from servlet

Avatar

Level 5

Hi Experts,

  We have two ways of registering a sling servlet

  1. Registering through path
  2. Registering through resource type.

Say we use the second option, I have a page component /sampleproject/page/homepagecomponent and i register a servlet using this component. This means whenever i access a page created using this component(/content/home.html) the servlet will get invoked and the response from the servlet will be used to render the page. It does not matter whether the call is from the browser or it is an Ajax call. 

If my above understanding is correct can we cache the response from the servlet in dispatcher through this option? Usually say we use something like /bin/myservlet as path for servlet, in disptacher we will allow this path to hit the publish instance and we will not cache it. I am trying to cache the response from the servlet as well. Please help me with your inputs.

Thanks,

Jai.

1 Accepted Solution

Avatar

Correct answer by
Employee

You can only cache responses that have an extension.

See here more detailed info: https://docs.adobe.com/content/docs/en/dispatcher.html

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

You can only cache responses that have an extension.

See here more detailed info: https://docs.adobe.com/content/docs/en/dispatcher.html

Avatar

Level 9

Hi,

That's one way to cache the response from servlet. Another way is that you have to use /bin/servlet.json or html and also allowed this path at the dispatcher level.

Regards,

Jitendra