We are facing an issue in an AEM AMS environment related to Dispatcher caching behavior when query parameters are present in the request URL.
We are using ACS Commons Dispatcher Max-Age Header Filter with the following configuration:
com.adobe.acs.commons.http.headers.impl.DispatcherMaxAgeHeaderFilter~pages.cfg.json
{
"max.age": "7200",
"filter.pattern": [
"^/.*$"
]
}
For a request without query parameters, for example:
https://mydomain.com/en/about
Dispatcher cache is generated correctly with the following files:
The browser response headers also contain:
Cache-Control: max-age=7200
For a request with query parameters, for example:
https://mydomain.com/en/about?abc=xyz
Observed behavior:
Dispatcher cache generates only:
The browser response headers do not include: Cache-Control: max-age=7200
It appears that when a query parameter is present:
The Dispatcher Max-Age Header Filter is not applied
As a result, the TTL file is not created, and the Cache-Control header is missing
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Sady_Rifat ,
The DispatcherMaxAgeHeaderFilter extends AbstractDispatcherCacheHeaderFilter and uses the hasValidParameters(HttpServletRequest request) method to validate query parameters:
private boolean hasValidParameters(HttpServletRequest request) {
if (this.allowAllParams) {
return this.blockParams.stream().noneMatch((blockParam) -> request.getParameterMap().containsKey(blockParam));
} else {
return request.getParameterMap().isEmpty() || this.passThroughParams.containsAll(request.getParameterMap().keySet());
}
}
In your configuration:
Therefore, the filter does not apply the Cache-Control header, and the TTL file is not created.
Solution
Update the OSGi configuration to allow query parameters:
{
"max.age": "7200",
"filter.pattern": [
"^/.*$"
],
"allow.all.params": true,
"block.params": ["param1", "param2"] // Optional: specify parameters to block
}
{
"max.age": "7200",
"filter.pattern": [
"^/.*$"
],
"pass.through.params": ["abc", "xyz"]
}
To sum up:
allow.all.params=true for broad allowance or pass.through.params for selective allowance.Cache-Control header will be applied, and TTL files will be generated even when query parameters are present.
Hi @Sady_Rifat ,
The DispatcherMaxAgeHeaderFilter extends AbstractDispatcherCacheHeaderFilter and uses the hasValidParameters(HttpServletRequest request) method to validate query parameters:
private boolean hasValidParameters(HttpServletRequest request) {
if (this.allowAllParams) {
return this.blockParams.stream().noneMatch((blockParam) -> request.getParameterMap().containsKey(blockParam));
} else {
return request.getParameterMap().isEmpty() || this.passThroughParams.containsAll(request.getParameterMap().keySet());
}
}
In your configuration:
Therefore, the filter does not apply the Cache-Control header, and the TTL file is not created.
Solution
Update the OSGi configuration to allow query parameters:
{
"max.age": "7200",
"filter.pattern": [
"^/.*$"
],
"allow.all.params": true,
"block.params": ["param1", "param2"] // Optional: specify parameters to block
}
{
"max.age": "7200",
"filter.pattern": [
"^/.*$"
],
"pass.through.params": ["abc", "xyz"]
}
To sum up:
allow.all.params=true for broad allowance or pass.through.params for selective allowance.Cache-Control header will be applied, and TTL files will be generated even when query parameters are present.
Thanks for that much detail.
Views
Replies
Total Likes
he Dispatcher Max-Age Header Filter skips requests with query parameters by default.
Set "allow.all.params": true to allow all query params, or "pass.through.params": ["abc","def"] to allow specific ones.
After this, Cache-Control headers and TTL files will be applied even when query strings are present.
Views
Like
Replies
Views
Likes
Replies