Expand my Community achievements bar.

Caching API response on dispatcher

Avatar

Level 4

Hi All,

I am integrating AEM with Hybris. On product page I make an API call to Hybris to get product data which returns response in form of JSON.

As my product data would not change much so I want to cache the JSON response on dispatcher. How in my code I can make sure that when product data is requested it is served from dispatcher and no call goes to Hybris if it is cached if not cached my code should make the API call. Please can someone give pointer configuration and approach required to achieve this use case

Thanks,

Shehjad

1 Reply

Avatar

Level 7
Hi, it depends on how you are using the api. If you are using a servlet with ajax to get the json and render the data in javascript the dispatcher already cache this json. Otherwise if you are using a model remember that the html of the page is cached on the dispatcher so the call vs hybris is not performed everitime.