Expand my Community achievements bar.

SOLVED

[GraphQL] How to invalidate cached results of Persisted Queries on dispatcher?

Avatar

Level 3

Reading from https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/g... I believe JSON results of persisted GraphQL queries can be cached at both Dispatcher and CDN level, is this understating correct?

 

If yes, then how can we invalidate these cached JSON files on Dispatcher? (Apparently there is no correspondent resources to be published which triggers the invalidation like a webpage)

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

No, it is only for cdn.

For delete the dispatcher cache without publishing anything, there is another way to do it by using ACS common solution 

https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-ui/index.html 



Arun Patidar

View solution in original post

5 Replies

Avatar

Community Advisor

Hi,

I think you can cache the response in order to improve the performance but using cache-control header

 

{
"query": " query getAllAdventureDetails($fragmentPath: String!) { adventureByPath(_path: $fragmentPath){ item { _path adventureTitle adventureActivity adventureType adventurePrice adventureTripLength adventureGroupSize adventureDifficulty adventurePrice adventurePrimaryImage{ ...on ImageRef{ _path mimeType width height } } adventureDescription { html json } adventureItinerary { html json } location { _path name description { html json } contactInfo{ phone email } locationImage{ ...on ImageRef{ _path } } weatherBySeason address{ streetAddress city state zipCode country } } instructorTeam { _metadata{ stringMetadata{ name value } } teamFoundingDate description { json } teamMembers { fullName contactInfo { phone email } profilePicture{ ...on ImageRef { _path } } instructorExperienceLevel skills biography { html } } } administrator { fullName contactInfo { phone email } biography { html } } } _references { ...on ImageRef { _path mimeType } ...on LocationModel { _path __typename } } } }",
"cache-control": { "max-age": 300 }
}

 



Arun Patidar

Avatar

Level 3

hi @arunpatidar , thanks for your reply.

but my question is how to invalidate cache (specifically on Dispatcher), not how to cache.

btw, I thought

"cache-control": { "max-age": 300 }

is intended for CDN usage but not for dispatcher, are you suggesting it is used by dispatcher too?

Avatar

Correct answer by
Community Advisor

Hi,

No, it is only for cdn.

For delete the dispatcher cache without publishing anything, there is another way to do it by using ACS common solution 

https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-ui/index.html 



Arun Patidar

Avatar

Level 3

ok, what if we just cache persistent query result on CDN but not Dispatcher, do you see any issues with this?

Avatar

Community Advisor

No issues if the request is not reaching the publisher for every request.

it could be a dispatcher or CDN



Arun Patidar