Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

AEMaaCS - How to remove default Cache-Control on HTML responses?

Avatar

Community Advisor

Hi All,

 

I am trying to disable cache for HTML responses. I have these rules already in dispatcher config,

 

<LocationMatch "^/content/.*\.html$">
Header always unset Cache-Control
Header always unset Expires
Header always set Cache-Control "no-store, no-cache, max-age=0, must-revalidate"
Header always set Pragma "no-cache"
Header always set Surrogate-Control "no-store"
</LocationMatch>

 

However, when I check response headers I still see this:

cache-control: no-store, no-cache, max-age=0, must-revalidate,max-age=300

 

It looks like max-age=300 is being appended somewhere. I want to know from where this default Cache-Control: max-age=300 is getting added? What is the recommended way to override / remove this so my own no-cache rules are effective?

 

Thanks in advance !

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Resolved the default HTML caching issue by following this documentation,https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/con...

Dispatcher configuration sets some default caching headers for text/html content type.

  • by default, cached by the browser for five minutes, based on the cache-control header emitted by the Apache layer. The CDN also respects this value.
  • the default HTML/Text caching setting can be disabled by defining the DISABLE_DEFAULT_CACHING variable in global.vars:
Define DISABLE_DEFAULT_CACHING
 

 

 

View solution in original post

4 Replies

Avatar

Community Advisor

I missed to add this as part of my question. We do not have any other CDN on top of Fastly. And no other rules added on dispatcher for caching.

Avatar

Correct answer by
Community Advisor

Resolved the default HTML caching issue by following this documentation,https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/con...

Dispatcher configuration sets some default caching headers for text/html content type.

  • by default, cached by the browser for five minutes, based on the cache-control header emitted by the Apache layer. The CDN also respects this value.
  • the default HTML/Text caching setting can be disabled by defining the DISABLE_DEFAULT_CACHING variable in global.vars:
Define DISABLE_DEFAULT_CACHING
 

 

 

Avatar

Community Advisor

Hi @Ganthimathi_R,

I think it's either (a) another vhost/dispatcher rule that sets max-age=300, often in default.vhost or a base file that loads after yours, or (b) publish-side code doing response.setHeader("Cache-Control", "max-age=300…"). Fastly won’t add 300 by itself.

Try this:

<LocationMatch "^/content/.*\.html$">
  # wipe both header tables
  Header unset Cache-Control
  Header always unset Cache-Control
  Header unset Expires
  Header always unset Expires

  # set once, at the very end
  Header always set Cache-Control "no-store, no-cache, max-age=0, must-revalidate"
  Header always set Pragma "no-cache"
  Header always set Surrogate-Control "no-store"
</LocationMatch>

also:

  • Ensure this block is in the vhost that loads last (or move it to default.vhost), so nothing overwrites it later.

  • Grep your codebase for setHeader("Cache-Control" and remove any max-age=300 on HTML responses.

and verify:

curl -I https://your.site/.../page.html | tr -d '\r' | egrep -i 'cache-control|surrogate-control'

You should see a single Cache-Control (your value) and Surrogate-Control: no-store.


Santosh Sai

AEM BlogsLinkedIn


Avatar

Level 5

Hi @Ganthimathi_R 

The max-age=300 is coming from dispatcher’s default caching (not Apache).

In dispatcher.any, allow dispatcher to forward your custom headers instead of appending its own:

/cache
{
  /headers
  {
    "Cache-Control"
    "Pragma"
    "Surrogate-Control"
  }
}

Then your <LocationMatch> rules will take effect and max-age=300 won’t be added.

 

Hope this helpful.:)

 

Regards,

Karishma.