Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Header/Footer from external service

Avatar

Level 1

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

AEM BlogsLinkedIn


View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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

AEM BlogsLinkedIn