How to configure Dispatcher to cache persisted query requests? | Community
Skip to main content
Level 2
April 14, 2023
Solved

How to configure Dispatcher to cache persisted query requests?

  • April 14, 2023
  • 1 reply
  • 768 views

According to the article [link], "Persisted queries are recommended as they can be cached at the Dispatcher and Content Delivery Network (CDN) layers", but I am struggling to find information on how to configure the Dispatcher cache in this article. I have tried to follow [this] add allow rules in the /cache setting, but still find it not cached. And no files related to this query get generated in the dispatcher cache folder. (The dispatcher cache works well currently on page contents). 

Can anyone provide guidance on how to configure Dispatcher to cache persisted query requests? Any insights or resources on this topic would be greatly appreciated.

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 kaikubad

You need to add rule to dispatcher for caching.

To cache all use the following code in ams_publish_cache.any

## Default allow all items to cache
/0000 {
/glob "*"
/type "allow"
}
## Don't cache csrf login tokens
/0001 {
/glob "/libs/granite/csrf/token.json"
/type "deny"
}

 To cache specific url parameter use following code

/cache
{
/docroot "/path/to/docroot"
/rules
{
/0000
{
/type "allow"
/url "/content/*"
/cache
{
/enable "1"
/useFilesystem "0"
}
}
}
/cache
{
/docroot "/path/to/cache"
/type "file"
/urlparams "param1,param2"
}
}

1 reply

kaikubad
Community Advisor
kaikubadCommunity AdvisorAccepted solution
Community Advisor
April 28, 2023

You need to add rule to dispatcher for caching.

To cache all use the following code in ams_publish_cache.any

## Default allow all items to cache
/0000 {
/glob "*"
/type "allow"
}
## Don't cache csrf login tokens
/0001 {
/glob "/libs/granite/csrf/token.json"
/type "deny"
}

 To cache specific url parameter use following code

/cache
{
/docroot "/path/to/docroot"
/rules
{
/0000
{
/type "allow"
/url "/content/*"
/cache
{
/enable "1"
/useFilesystem "0"
}
}
}
/cache
{
/docroot "/path/to/cache"
/type "file"
/urlparams "param1,param2"
}
}