I am using AEM as a Cloud Service and have created a component in which the data is rendered through the Content Fragments. To get the data stored in CFs, I have a GET request in my JS for the graphql persisted query. But the problem is the data is cached. No matter how many times I publish the CF, the data remains same and is updated after one day around or may take several days to be shown updated. This doc: https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/g... states that GET request in persisted queries are cached. But I don't want my request to be cached. How can I do that?
Solved! Go to Solution.
Views
Replies
Total Likes
Got the solution for this. Just added cache headers for the graphql in dispatcher and it worked.
Hi @nikita24tailor ,
The same document talks about using cache-control - max-age feature to control caching. Have you tried that?
Thanks,
Ritesh Mittal
I tried but didn't get the idea for the fields provided in the Headers. If you can tell me which fields do I need to set in the Headers to stop caching, that would be helpful.
Try setting cache control max-age as 0. This will make the TTL as zero and response will be invalidated. Also, make sure to use right cache mechanism. For example, if you have both generic (cachable) and personalized (non-cachable) content coming from API, then combining responses on client side can also be considered.
Check the below explanation
Tried but didn't get the required results. I did set the max-age to 0, s-max-age to 0 and stale-while-revalidate to 0. But s-max-age does not change and is reflected as 7200 on publish.
try this.
Cache-Control: no-cache
Got the solution for this. Just added cache headers for the graphql in dispatcher and it worked.
Can you please show how you added the header in dispatcher for GraphQL?
can u tell what rule u added for the header in dispatcher for GraphQL???
Views
Replies
Total Likes
Please share the headers added for graphql in dispatcher. thank you.
Views
Replies
Total Likes
This is the rule which I've added.
# GraphQL cache rules for persistent queries
/0020 {
/glob "/graphql/execute.json/*"
/type "deny"
}