Enable AEM Dispatcher caching
Recommendation
AEM Dispatcher is the first level cache within the AEM service, before CDN cache.
Further Reference
See:
Use a Content Delivery Network (CDN)
Recommendation
GraphQL queries and their JSON responses can be cached if targeted as GET
requests when using a CDN. In contrast, uncached requests can be very (resource) expensive and slow to process, with the potential for further detrimental effects on the origin’s resources.
Further Reference
See:
Set HTTP cache control headers
Recommendation
When using persisted GraphQL queries with a CDN, it is recommended to set appropriate HTTP cache control headers.
Each persisted query can have its own specific set of cache control headers. The headers can be set over the GraphQL API or the AEM GraphiQL IDE.
Further Reference
See:
GraphQL Query optimization
On an AEM instance with a high number of Content Fragments that share the same model, GraphQL list queries can become costly (in terms of resources).
This is because all fragments that share a model being used within the GraphQL query have to be loaded into memory. This consumes both time and memory. Filtering, which may reduce the number of items in the (final) result set, can only be applied after loading the entire result set into memory.
This can lead to the impression that even small result sets (can) lead to bad performance. However, in reality the slowness is caused by the size of the initial result set, as it has to be handled internally before filtering can be applied.
To reduce performance and memory issues, this initial result set has to be kept as small as possible.
AEM provides two approaches for optimizing GraphQL queries:
Each approach has its own use-cases and limitations. This section provides information on Hybrid Filtering and Paging, together with some of the best practices for use in optimizing GraphQL queries.