Expand my Community achievements bar.

SOLVED

Compress model json and content fragment APIs - Performance improvement

Avatar

Level 3

Hi Team,

I've got a performance problem to tackle in AEM as a Cloud Service based project.

Our setup consists of an headless SPA -  a next js web application and a mobile app rely on page model APIs and content fragment APIs (Jackson JSON exporter) to render content. Some of these json payloads can go upto 9mb's and this causes noticeable slow page load times. Can you suggest options to compress the json responses ?

I've looked at adding a sling filter as described here but it doesn't seem to be affecting anything.

Where can I add custom code to compress the response before it goes to the client ?

 

Thanks.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

You could compress the response at the Dispatcher layer. Check this link for more information: Enable Text Compression in AEM.

But ideally, you should break down that huge response. If you are using GraphQL to export the Content Fragments, you could add pagination and ensure the query is optimal. Please refer to this link for details: GraphQL API for Content Fragments - Paging. Regarding Sling Models, make sure you are exposing only the necessary information and not extra information such as JCR properties.

 

Hope this helps.



Esteban Bustamante

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi,

 

You could compress the response at the Dispatcher layer. Check this link for more information: Enable Text Compression in AEM.

But ideally, you should break down that huge response. If you are using GraphQL to export the Content Fragments, you could add pagination and ensure the query is optimal. Please refer to this link for details: GraphQL API for Content Fragments - Paging. Regarding Sling Models, make sure you are exposing only the necessary information and not extra information such as JCR properties.

 

Hope this helps.



Esteban Bustamante

Avatar

Level 3

We have trimmed down the information to the bare minimum.

Thanks for your suggestion on tackling this from the dispatcher layer. I'll check it out.

Avatar

Employee Advisor

The fact, that the JSON file is 9MB in size has 2 implications:

  1. The download time from the CDN (in which compressing the JSON can help),
  2. but also the parsing of that JSON on the client device; and this time is not improved by compressing the the file.

I recommend you to test the performance of your application on a device, which is on the lower end of the devices your audience is using (for example a 2 year old smartphone, which was a mid-to-low end range of the devices sold in 2022).

 

My gut feeling is, that the rendering time of the initial view of this site is quite high; and depending on the site this will reduce already the number of visitors.