[GraphQL] How to invalidate cached results of Persisted Queries on dispatcher? | Community
Skip to main content
Level 3
May 9, 2022 9:52 AM UTC
Solved

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

Reading from https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/graphql/advanced-tutorial/graphql-persisted-queries.html?lang=en 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)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
May 9, 2022 4:46 PM UTC

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

5 replies

arunpatidar
New Participant
May 9, 2022 12:03 PM UTC

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 }
}

 

Translate
Arun Patidar
baoyu_liAuthor
Level 3
May 9, 2022 1:35 PM UTC

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?

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
May 9, 2022 4:46 PM UTC

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 

Translate
Arun Patidar