Header/Footer from external service | Community
Skip to main content
December 13, 2022
Solved

Header/Footer from external service

  • December 13, 2022
  • 1 reply
  • 687 views

Hi Everyone - I have a requirement to consume header/footer hosted on our react application. React team has built an endpoint for both header and footer which when called return complete html ( including js and css references). I was planning to build a simple header and footer component and through SlingModel call these two endpoints and include api response. These components will then be included in experience fragments and will be part of editable templates. 

My concern/question is will there be call to SlingModel ( which in turn will make an http call to react api's) for every page built using editable template? If yes, how can i limit backend API calls to just one time and then use the response for all the pages?

 

Thanks in advance.

 

~Pragya

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SantoshSai

Hi @praja1987,

Please check this Sling Model Caching, it may helps you to avoid multiple invocation.

https://sling.apache.org/documentation/bundles/models.html#caching

You only have to specify cache=true in the Model-annotation.

@Model(adaptable = SlingHttpServletRequest.class, cache = true)
public class ModelClass {
   ...
}  

Regards,

Santosh 

1 reply

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorAccepted solution
Community Advisor
December 13, 2022

Hi @praja1987,

Please check this Sling Model Caching, it may helps you to avoid multiple invocation.

https://sling.apache.org/documentation/bundles/models.html#caching

You only have to specify cache=true in the Model-annotation.

@Model(adaptable = SlingHttpServletRequest.class, cache = true)
public class ModelClass {
   ...
}  

Regards,

Santosh 

Santosh Sai