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

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

  • May 9, 2022
  • 1 reply
  • 1901 views

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.
Best answer by arunpatidar

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 

1 reply

arunpatidar
Community Advisor
Community Advisor
May 9, 2022

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
baoyu_liAuthor
Level 3
May 9, 2022

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?

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
May 9, 2022

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