Score:0

Why is the Cache-Control always "no-cache" and "X-Drupal-Dynamic-Cache" UNCACHEABLE on this site?

kn flag

I have a production website for quite a long time now. By digging, we found that the Cache-Control was always to "no-cache" and "X-Drupal-Dynamic-Cache" is UNCACHEABLE

enter image description here

My settings.prod.php look like this

# ================================================================
# Performance settings
# ================================================================
$config['system.logging']['error_level'] = ERROR_REPORTING_HIDE;
$config['system.performance']['cache']['page']['max_age'] = 86400;
$config['system.performance']['css']['preprocess'] = TRUE;
$config['system.performance']['css']['gzip'] = TRUE;
$config['system.performance']['js']['preprocess'] = TRUE;
$config['system.performance']['js']['gzip'] = TRUE;

And this is my services.prod.yml

parameters:
  http.response.debug_cacheability_headers: false
  twig.config:
    debug: false
    auto_reload: false
    cache: true

I have both dynamic_page_cache and page_cache enable on the website, because we have both anonymous and logged users.

Furthermore, the config settings is not display in the backend System > Development > Performance, is the cache really activated like this ?

cn flag
Yes, config overrides don’t show up on the admin form unless the module developers have written some code to make that happen (some do but most don’t). Rather than global settings, it feels likely that something in the page build is declaring itself as uncacheable, and that’s bubbling up to the top level. You might have something varying on date, for example, sometimes people hook up the footer copyright year to a dynamic var without realising the cache implications
unusedspoon avatar
aq flag
If you're on D9.5 or above you could try turning this caching debug on and it might help trace what is causing the uncachable https://www.drupal.org/node/3162480 Common things like captchas and the facets module can cause the whole page to be uncachable
id flag
I agree with the commenters above. This isn't about site settings but rather something a module is doing.
apaderno avatar
us flag
There are many factors that could make a page not cacheable, including a session containing data.
Score:0
kn flag

I've uninstall page_cache and keept dynamic_page_cache to have a max-age=3600 enabled.

I've also remove a remaining killswitch which causes issue with custom block.

As it is a context user website (drupal commerce), when the user is adding a product, x-dynamic-cache became uncacheable

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.