So the module dynamic page caching is not working when used on authenticated users. When im not authenticated i can see MISS or HIT on X-Drupal-Dynamic-Cache header, but on authenticated users is always UNCACHEABLE, even for static contents. I'm not sure if is this a bug or im doing something wrong, anyway, i would like to know how to hanlde this behaviour.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rober.drupalizeme created an issue. See original summary.

borisson_’s picture

Assigned: rober.drupalizeme » Unassigned
Category: Bug report » Support request
Priority: Critical » Normal
Issue tags: -cache context tag key

This is a support request, support requests are never critical.

Also, please try to add steps to reproduce this issue. I'm not sure what's meant by "static contents" or how to reproduce that.

PS: The assigned field is used for when you start work on something, not when creating a new issue, I've set this to unassigned.

PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.

rober.drupalizeme’s picture

Sorry for misunderstandings

To reproduce the error

- Set the cache debug headers (so you can see if the page is being cached)
- Load the page in auth mode and in anonymous mode.
- In auth mode you can see X-Drupal-Dynamic-Cache: "UNCACHEABLE"
- In non auth mode you can see X-Drupal-Dynamic-Cache: "MISS"

UPDATE: I've been able to remove the UNCACHEABLE message by editing services.yml, but my app is still not caching at all, this is the header is always X-Drupal-Dynamic-Cache: "MISS"

Berdir’s picture

what modules do you have installed? what kind of blocks are on those pages? can you reproduce with a default installations?

If you have a debugger, you can give you some hints on where to add breakpoints to figure this out.

Sinan Erdem’s picture

I can reproduce this on a fresh install. Dynamic cache never seems to HIT for an authenticated user. I have installed devel/profiler and it shows that the dynamic cache is always a MISS. No extra modules installed. X-Drupal-Dynamic-Cache is UNCACHEABLE all the time (homepage, node, etc)

Berdir’s picture

Status: Active » Postponed (maintainer needs more info)

There have been some reports that blocks with node type conditions or possibly related special blocks are causing this. What kind of blocks, modules and configurations do you have that might be special?

Sinan Erdem’s picture

Hi Berdir, this is a fresh standard installation.

Sinan Erdem’s picture

FileSize
47.19 KB
303.02 KB

Generic steps to reproduce this issue:

1. Go to https://simplytest.me/ and launch a box by selecting Devel 8.0 module.
2. Install Drupal as usual.
3. Go to Extensions and enable Devel and Web Profiler.
4. Go to homepage, refresh the page a couple of times.
5. Now you can see from either Web profiler or from Browser's Network tool that Drupal Dynamic cache is UNCACHEABLE. Screenshots attached.

Berdir’s picture

user 1 and definitely devel/webprofiler likely add per-user information, that makes perfect sense that it can't be cached then.

It makes more sense to test with normal-ish users that don't have complicated access logic, e.g. for toolbar menu items.

tacituseu’s picture

willzyx’s picture

@tacituseu I do not think that is the toolbar module is in se that cause this issue... I think that some implementations of the hook_toolbar like user_toolbar() and shortcut_toolbar() add uncacheable cache contexts or cache contexts with with an high cardinality and this cause the problem..
A proof of that? try to disable shortcut module and enable the testing module toolbar_disable_user_toolbar on a clean installation and you will see that the issue is gone

@Berdir For what I know both webprofiler and devel toolbar implementation are compatible with the dynamic page cache and not cause the page to be uncacheable

tacituseu’s picture

@willzyx: makes sense, user_toolbar() and shortcut_toolbar() both add 'user' context.

Sinan Erdem’s picture

I have a confusion about dynamic page cache. I thought it will be useful when there is user specific information on the page. Otherwise static page cache would be enough.

If there is user specific information on the page, is that mean all page would become uncacheable?

Sinan Erdem’s picture

I can confirm that disabling Toolbar module resolves the issue. dynamic cache is HIT after disabling toolbar.

penyaskito’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Looks like works as designed then. Thanks!

FlutterStack’s picture

I tried disabling Toolbar module but for me issue hasn't solved.