Expand my Community achievements bar.

Best approach for making single JSON call - re-priming issue for child & parent JSON

Avatar

Level 4

Hi all,

 
Hope everyone is doing great !
 
Use case:
AEM is exposing 2 types  of content JSON (child.json & parent.json) to our consumers (outside AEM). JSON count is high (say 50K for parent.json). These json just contain content which was captured in AEM.
 
We can have 2 approach for exposing JSON
 
Approch # 1 (one json call i.e., merge the content of child.json into parent.json)
 
Advantage
Consumer will be making 1 network call to json (which is parent.json) instead of 2 JSON call (child.json & parent.json)
 
Disadvantage 
If child.json changes and there are 10K parents then i will need to re-prime 10K parents on dispatcher
 
Approch # 2 (two json call - child.json & parent.json)
 
Advantage
We do not need to worry about repriming of parent.json in case child.json changes
 
Disadvantage 
Consumer of json has to  make  two JSON calls instead of 1. So this might impact load time of their pages
 
NOTE : We will have Akamai to cache the JSON
 
Our preference is approach # 1 but at the same time we do not want to reprime the parent.json in case child changes. Is there any concept similar to SSI which can help in this situation ?
 
Thanks in advance.
3 Replies

Avatar

Level 10

Can you please explain your use case in more detail - what are you doing with the returned JSON? Have you written any custom servlets that produce the JSON? 

Avatar

Level 4

Hi,

Thanks for replying on this.

Yes we have written custom json. Its a JSP (which has the logic for creating JSP). JSON is pretty simple. All its doing is just reading the node properties (under jcr:content) and outputting in form on JSON.

For example:

We have node /content/project1/home

It has got 2 component to capture content 

/content/project1/home/jcr:content/node1

/content/project1/home/jcr:content/node2

So now if you hit /content.project1/home.content.json then it will give 

{

node1:

    {

        property1 : "Value for property1",

        property2 : "Value for property2",

        property3 : "Value for property3"

    }

node2:

    {

        property1 : "Value for property1",

        property2 : "Value for property2",

        property3 : "Value for property3"

    }

}

 

Let me know if this helps. I can put more details if needed.

Avatar

Level 10

I would look at using a Sling Servlet that uses this API to traverse through the JCR nodes:

http://jackrabbit.apache.org/api/2.2/org/apache/jackrabbit/commons/flat/TreeTraverser.html

Did you use JCR API to read nodes or are you using another approach?