I have a resource type (test/test-code-reader) sling servlet and I call the servlet like the below URL:
http://localhost:4502/content/dam/test-code-reader?id=36503786-4aea-4fe6-99a1-536bd7488ad5
My resource type node is residing in /content/dam/test-code-reader and hence calling that URL and then appending the query parameter to the URL.
Use case: Here I am passing a parameter id which is basically the UUID of an asset. I use this UUID to get some metadata property value of an asset to redirect to the URL in the metadata.
Results: In my local everything is working fine as expected. But when it comes to CDN level, Akamai ignores all query parameters.
Expectation: I don't want this requests from my servlet to be cached as each time I will be calling using a different/dynamic UUID. How can I set dispatcher and Akamai to ignore this query parameter, so that the requests from my servlet with this query parameter never gets cached.
I can see the below configurations for cache in our dispatcher. From what I understand it says to cache all pages.
How can I set my Akamai and dispatcher config to work in such a way that this request with a query parameter id is never cached? I read in documentation to use ignoreUrlParams in this dispatcher configuration. If so, can someone help me with the rule to add both in dispatcher and Akamai level?
@lukasz-m @arunpatidar @Raja-kp @kautuk_sahni @Nupur_Jain
Solved! Go to Solution.
Views
Replies
Total Likes
If no headers-cache are created in the AEM origin and in the dispatcher, then the CDN is somehow caching it: in this case there might be a problem with the configuration on the CDN layer because it would be a really weird and error-prone behavior to cache even a dynamic request by default.
I agree with you that using the servlet for adding in the response a no-cache header would probably fix the issue but here I would investigate the issue with the CDN and avoiding any further redundant patch in the core.
A possible approach for understanding the situation is to perform the dynamic GET request separately to the AEM origin and to the dispatcher instance, so that you will be able to see (it's enough to use the browser's developer tool or i.e. the curl command) where the cache headers are created (or not) in the response.
If the response hits the CDN layer without cache headers, then I would go for a CDN configuration fix. If the cache headers are created I would avoid their creation in the origin or in the dispatcher layers.
Hi @P_V_Nair
Looks like you have enabled everything(based on above screenshot), you should deny access to all files and then allow access to specific areas. (whitelist pattern).
/0001 { /glob "*" /type "deny" }
/0002 { /type "deny" /url "*.asp" }
if queryString parameter caching is enabled in dispatcher, Check /ignoreUrlParams section of dispacher.any file if it has any rules defined like:
/ignoreUrlParams { /0001 { /glob "*" /type "deny" } /0002 { /glob "q" /type "allow" } }
This rule makes the query param request cacheable and basically ignores query param "q" for further request and returns the same cached response.
Reference: https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/configuring/dispatcher-co... and read more on ignoreUrlParams section.
Hope it helps you!
Regards,
Santosh
Hi @P_V_Nair
First to disable cache at Dispatcher enable the cache rule for your servlet url in dispatcher.any under cache
example:
/0004 | |
{ | |
/glob "/content/dam/test-code-reader*" | |
/type "deny" | |
} |
For Disabling cache in Akamai under the specific domain web property add a cache exclusion rule for the above mentioned url. then it will stop caching the servlet.
Regards,
Rajashankar.R
By defualt dispatcher does not cache if you pass query parameter.
Akamai maybe using the complete GET URL as cache key for caching, you can pass a current time stamp to the url or bypass Akamai by passing no-store header or adjust setting at akamai to not cache this page.
response.setHeader("Dispatcher", "no-cache");
response.setHeader("Cache-Control", "no-store");
https://helpx.adobe.com/experience-manager/kb/DispatcherNoCache.html
@arunpatidar Does that mean that i need to set the above response headers from my servlet or directly we can do some configuration changes at Akamai interface level to not to cache this servlet requests with id as query param?
you can set this headers in your Servlet .
If no headers-cache are created in the AEM origin and in the dispatcher, then the CDN is somehow caching it: in this case there might be a problem with the configuration on the CDN layer because it would be a really weird and error-prone behavior to cache even a dynamic request by default.
I agree with you that using the servlet for adding in the response a no-cache header would probably fix the issue but here I would investigate the issue with the CDN and avoiding any further redundant patch in the core.
A possible approach for understanding the situation is to perform the dynamic GET request separately to the AEM origin and to the dispatcher instance, so that you will be able to see (it's enough to use the browser's developer tool or i.e. the curl command) where the cache headers are created (or not) in the response.
If the response hits the CDN layer without cache headers, then I would go for a CDN configuration fix. If the cache headers are created I would avoid their creation in the origin or in the dispatcher layers.
Hi,
Can you check the response header at client side? what headers are you receiving?
Could be possible that dispatcher or akamai removing those headers set from AEM.
By default the dispatcher does not cache requests which do have a query parameter. With Akamai I am not sure, but it should be easily possible to do the same.
Views
Likes
Replies
Views
Likes
Replies