Hello Team,
In my AEM application, I have tab component. Kept "Component-1" in 1st Tab item section. In this feature, from backend logic, I am fetching the data from 3rd party application via GraphQL. From this I am getting many details like: values, images list.
Now, in 2nd Tab item section, I have kept " Component-2". Here, In this component, I need to fetch the same values as above. But, I do not want to call 3rd party application again from my backend.
Note: I cannot move the logic of calling the 3rd party application via graphQL to javascript.
So, I am thinking about Once I get the data from backend of "Component-1", need to keep this data in cookies, or local storage. Then, utilize the same while displaying the data in 2nd tab item section.
Let me know your opinion. Thanks in advance
Views
Replies
Total Likes
Adding my suggestion.
If you are calling JS clientlibs from component level, the call will be triggered based on number of times you have authored the component.
Rather than storing the data in cookies / local storage, you can call the javascript client library at page template level
Hope this helps
Thanks
Views
Replies
Total Likes
Views
Replies
Total Likes
Calling the GraphQL api from java itself.
Views
Replies
Total Likes
Hi @Mahesh_Gunaje ,
You can use in-memory caching to optimize repeated data access. Another approach would be to store the response in a service variable.
Create a Common Service with a Service Variable:
Use an Identifier to Control API Calls:
Reuse Cached Response for Component-2:
This method allows both components to share data efficiently without redundant API calls.
I cannot move the "calling the GraphQL query" to javascript section. Since, the logic is too heavy to move the logic from java to javascript.
Views
Replies
Total Likes
You might consider exploring an in-memory caching solution.
One approach is to cache the API response per page and reuse it as needed within the page or based on specific logic.
In our project, we’re using Guava Cache to store responses in memory with a configurable time-to-live (TTL) to efficiently manage cache expiration.
Thanks @arunpatidar @narendiran100 for your help.
Let me think about some in-memory caching mechanism.
One general Query: Is in-memory caching is the solution for component communication in AEM? I mean, I am 100% sure that wherever my 2 components (Component-1, component-2) is used,it is used together only. That is authored in my Tab component. I mean 1st Tab item: Component-1, 2nd Tab Item - Component-2.
Now, sling model of component-1 has heavy logic to hit the 3rd party GraphQL API and get the response. process it. Passes this to Sightly.
Views
Replies
Total Likes
Hi @Mahesh_Gunaje
In AEM, You generally store content in JCR node and when you need to share the content, you use path reference pattern.
But here you can't use that because data does not exists anywhere in AEM.
Views
Likes
Replies
Views
Likes
Replies