Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.
SOLVED

ACS Commons TTL is not generated when the URL has query parameter

Avatar

Community Advisor

We are facing an issue in an AEM AMS environment related to Dispatcher caching behavior when query parameters are present in the request URL.

Current Setup

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": [
    "^/.*$"
  ]
}

Expected / Working Behavior (without query parameters)

For a request without query parameters, for example:

https://mydomain.com/en/about

Dispatcher cache is generated correctly with the following files:

  • about.html
  • about.html.h
  • about.html.ttl

The browser response headers also contain:

Cache-Control: max-age=7200

Issue (with query parameters)

For a request with query parameters, for example:

https://mydomain.com/en/about?abc=xyz

Observed behavior:

  • Dispatcher cache generates only:

    • about.html
    • about.html.h
  • The .ttl file is not generated
  • 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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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:

  • allowAllParams = false
  • Request contains query parameters
  • No pass.through.params defined in OSGi config

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:

Option 1: Allow all parameters
{
  "max.age": "7200",
  "filter.pattern": [
    "^/.*$"
  ],
  "allow.all.params": true,
  "block.params": ["param1", "param2"] // Optional: specify parameters to block
}

 

Option 2: Allow specific parameters
{
  "max.age": "7200",
  "filter.pattern": [
    "^/.*$"
  ],
  "pass.through.params": ["abc", "xyz"]
}

 

To sum up:

  • By default, the filter excludes requests with query parameters unless explicitly configured.
  • Use allow.all.params=true for broad allowance or pass.through.params for selective allowance.
  • After updating the configuration, the Cache-Control header will be applied, and TTL files will be generated even when query parameters are present.
Kostiantyn Diachenko


Check out AEM VLT Intellij plugin


View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

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:

  • allowAllParams = false
  • Request contains query parameters
  • No pass.through.params defined in OSGi config

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:

Option 1: Allow all parameters
{
  "max.age": "7200",
  "filter.pattern": [
    "^/.*$"
  ],
  "allow.all.params": true,
  "block.params": ["param1", "param2"] // Optional: specify parameters to block
}

 

Option 2: Allow specific parameters
{
  "max.age": "7200",
  "filter.pattern": [
    "^/.*$"
  ],
  "pass.through.params": ["abc", "xyz"]
}

 

To sum up:

  • By default, the filter excludes requests with query parameters unless explicitly configured.
  • Use allow.all.params=true for broad allowance or pass.through.params for selective allowance.
  • After updating the configuration, the Cache-Control header will be applied, and TTL files will be generated even when query parameters are present.
Kostiantyn Diachenko


Check out AEM VLT Intellij plugin


Avatar

Community Advisor

Thanks for that much detail.

Avatar

Level 3

@Sady_Rifat -

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.