AEM persisted query is not getting cached in dispatcher | Community
Skip to main content
Mario248
Level 7
March 31, 2025
Question

AEM persisted query is not getting cached in dispatcher

  • March 31, 2025
  • 4 replies
  • 962 views

I created a graphql endpoint for my content fragment and it is working fine in author/publisher/dispatcher. Now I am trying to setup cache rule for the  AEM persisted query. I followed below doc and setup the dispatcher config. But the cache is not happening at dispatcher level. Note this is AMS (AEM 6.5.22)

 

https://experienceleague.adobe.com/en/docs/experience-manager-learn/getting-started-with-aem-headless/deployments/configurations/dispatcher-filters

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/deployment/dispatcher-caching

 

Add the variable to the Dispatcher file global.vars:

Define CACHE_GRAPHQL_PERSISTED_QUERIES
 
/src/conf.dispatcher.d/filters/dexa_publish_filters.any
/0152 { /type "allow" /method '(GET|POST|OPTIONS)' /url "/graphql/execute.json*" }

 

src/conf.dispatcher.d/cache/dexa_publish_cache.any

/0000 {
/glob "*"
/type "allow"
}
/0003 {
/glob "/graphql/execute*.json"
/type "allow"
}
## Don't cache csrf login tokens
/0001 {
/glob "/libs/granite/csrf/token.json"
/type "deny"
}

 

grapth endpint = 

https://{disp-domain-name}/graphql/execute.json/dexa/product1;contentFragmentLocation=/content/dam/scale;variation=master

 

I can see the json response in dispatcher but it is not getting cached. Below the log message. Is there any config that I should add to cache this persisted query 

 

[Fri Mar 28 05:03:28 2025] [D] [pid 2263756:tid 140498874312448] Found farm publishfarm for dexa-dev.adobe.net

[Fri Mar 28 05:03:28 2025] [D] [pid 2263756:tid 140498874312448] checking [/]

[Fri Mar 28 05:03:28 2025] [D] [pid 2263756:tid 140498874312448] request URL has no extension: /

[Fri Mar 28 05:03:28 2025] [D] [pid 2263756:tid 140498874312448] cache-action for [/]: NONE

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] Decomposing URL :

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] uri : / 

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] suffix : No suffix 

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] extension : No extension 

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] selector : No selectors 

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] Decomposing Complete

[Fri Mar 28 05:03:28 2025] [T] [pid 2263756:tid 140498874312448] Filter rule entry /0001 blocked 'GET / HTTP/1.1'

[Fri Mar 28 05:03:28 2025] [D] [pid 2263756:tid 140498874312448] Filter rejects: GET / HTTP/1.1

[Fri Mar 28 05:03:28 2025] [I] [pid 2263756:tid 140498874312448] "GET /" - blocked [publishfarm/-] 0ms

4 replies

narendiran_ravi
Level 6
April 1, 2025

Hi @mario248 ,

Could you please check if your default_rewrite.rules has the below rules

 

# Allow caching of persisted queries
RewriteCond %{REQUEST_URI} ^/graphql/execute.json
RewriteRule ^/(.*)$ /$1;.json [PT,L]
Mario248
Mario248Author
Level 7
April 1, 2025

Thanks for your response. I didn’t have this rewrite rule earliercbut I added it and tested it but still caching is still not happening in the dispatcher. Is there any other configuration I might be missing?

kautuk_sahni
Community Manager
Community Manager
April 1, 2025

@mario248 Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
Mario248
Mario248Author
Level 7
April 1, 2025

Thanks. I am still looking for a solution.

November 21, 2025

@mario248  Did you get any solution? I am also facing same issue.

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 21, 2026

The issue is that the rewrite rule shared by @narendiran_ravi isn’t being applied on your side. According to the logs, your query does not include an extension, which the rewrite rule is supposed to append. To resolve this, make sure the rewrite rule is active so that your query is transformed into a URL like the following:

 

https://{disp-domain-name}/graphql/execute.json/dexa/product1;contentFragmentLocation=/content/dam/scale;variation=master.json

 

Hope this clarifies things!

Esteban Bustamante
MeasurableBusinessResults
Level 3
January 21, 2026

I assume you are hitting the graphql endpoint with a GET request, as POST requests by definition never get cached in dispatcher.

Also URLs with parameters (?myquery=value) are never cached by default.
For your URL, the parameters are part of the path though, so they should be cached.

Finally, requests with "Authorization" headers are not cached (unless allowAuthorized is 1)

Your cache filter rules are actually redundant, as your first rule already allows everything to be cached (“*”)

So either drop the 0003 rule completely because its redundant in addition to rule 0000
or make it explicit like

  /glob "/graphql/execute.json/*"