Updated: Comment #39

Problem/Motivation

The note about the page cache module on the performance page is confusing, it looks like this only applies for the internal page cache module, but it doesn't.

Proposed resolution

Update the UI text to be more clear.

Remaining tasks

None.

User interface changes

Update the UI text to be more clear.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Status: Active » Needs review
FileSize
956 bytes
65.25 KB
61.81 KB
65.92 KB

Et voila!

Before
After

Bojhan’s picture

Looks good to me! I'd say RTBC if it comes back green :)

Status: Needs review » Needs work

The last submitted patch, 1: internal_page_cache_checkbox_states-2216161-1.patch, failed testing.

Wim Leers’s picture

The last submitted patch, 1: internal_page_cache_checkbox_states-2216161-1.patch, failed testing.

Wim Leers’s picture

znerol’s picture

I do not agree that this is useful. In Drupal 7 it was possible to use the internal cache without having to set Page cache maximum age. In my opinion this is a regression and #2177461: Refactor page caching into a service addresses that.

Wim Leers’s picture

#7: Interesting! So what does the "internal page caching" setting do if page caching itself is enabled? If you can point me to docs, that's fine too.

znerol’s picture

Use internal page cache is the checkbox formerly used to enable the page cache. I found where the regression was introduced: #1853086: Remove cache.page.enabled in favor of an explicit internal cache setting. The problem is this hunk:

--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -91,7 +91,8 @@ public function onRespond(FilterResponseEvent $event) {
     //   use partial page caching more extensively.
     // Commit the user session, if needed.
     drupal_session_commit();
-    if (config('system.performance')->get('cache.page.enabled') && ($cache = drupal_page_set_cache($response->getContent()))) {
+    $max_age = config('system.performance')->get('cache.page.max_age');
+    if ($max_age > 0 && ($cache = drupal_page_set_cache($response->getContent()))) {
       drupal_serve_page_from_cache($cache);
       // drupal_serve_page_from_cache() already printed the response.
       $response->setContent('');
Wim Leers’s picture

#9: are you saying that even if *no* max-age is configured, page caching should be possible? If so, could you explain the rationale behind that?

znerol’s picture

In Drupal 7 it was necessary to enable internal page caching in order make external page caching work. This is admittedly nonsense. In Drupal 8 the nonsense was just reversed and now internal page caching is only possible when external caching is configured.

In my opinion those two things simply do not need to be coupled together.

Wim Leers’s picture

I disagree with #11.

The "maximum age" setting serves *two* purposes:

  1. It determines the value of the Cache-Control/Expires headers, which you could indeed call "external page caching". It's about informing the browser how long it may cache this page (but also a reverse proxy cache between the server and the browser) .
  2. It determines the value of the expire column in the internal page cache, if internal page caching is enabled.

How does page caching make sense unless you can cache it only 0 seconds? Because that's precisely what "enable internal page caching but don't set a maximum age" implies.

Or am I missing something?

znerol’s picture

I agree with 1. However 2 does not match the current implementation. The maximum age setting does not have any influence on the expire-setting of the cache-object. It is true that drupal_page_set_cache will set the expire-attribute of the cache-object to a custom timestamp, but it will only do it if the Expire header was set by a custom module (core only sets it in drupal_serve_page_from_cache which comes after the cache object was saved). Normally the expire-attribute of the cache-object is set to CACHE_TEMPORARY (D7) and Cache::PERMANENT (D8) respectively.

Also I'd like to point out that it may be desirable to specify different expire-values for internal and external caches when delivering directly to the browser (no reverse-proxy). The internal cache should be as long living as possible, because we can purge it if necessary, while the external ttl should be set to a lower value on sites with frequent updates.

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
4.78 KB
78.22 KB

#13 A

2 does indeed not match the current implementation — I noticed that right after commenting — but isn't that a bug? Because:

     // Use the actual timestamp from an Expires header, if available.
    if ($date = $response->getExpires()) {
      $date = DrupalDateTime::createFromDateTime($date);
      $cache->expire = $date->getTimestamp();
    }

actually should should do just that, but it's failing because Drupal core does

$response->headers->set('Cache-Control', 'public, max-age=' . $max_age);

instead of using Symfony's addCacheControlDirective() method.

#13 B

Also I'd like to point out that it may be desirable to specify different expire-values for internal and external caches when delivering directly to the browser (no reverse-proxy). The internal cache should be as long living as possible, because we can purge it if necessary, while the external ttl should be set to a lower value on sites with frequent updates.

This I agree with, but only once #2124957: Replace 'content' cache tag with 'rendered' and use it sparingly is fully fixed.

And this then is completely broken also, because the maximum age you configure on the performance settings page is only set when a page is served from cache! This is also why it's named in a page cache-specific way.


So… as per #13 B, you've convinced me that the change I'm proposing in this issue does not make sense. However, if that's the case, we must still improve the usability of these settings, because right now it's very confusing. And we need to ensure caching is allowed on almost all pages (the exception being only admin pages?).

What do you think about this?

znerol’s picture

I would rather get rid of the Use the actual timestamp from an Expires header, if available. business. It does not make much sense to bind the expiry-attribute of the internal cache to any of the Expire / Cache-Control headers of the response.

The maximum age you configure on the performance settings page is only set when a page is served from cache!

No, that is actually not the case. On a cache-miss drupal_page_set_cache returns the cache-object and that is sent just like a cache-hit using drupal_serve_page_from_cache where the headers are applied. This is actually where the tight coupling between internal and external cache is coming from.

Regarding the new proposal: I like it very much. Setting Cache-Control: max-age is not only necessary for turning on the browser cache but also for operation behind a reverse proxy. This should be specified more explicit.

Wim Leers’s picture

I would rather get rid of the Use the actual timestamp from an Expires header, if available. business. It does not make much sense to bind the expiry-attribute of the internal cache to any of the Expire / Cache-Control headers of the response

I agree with the theory, but disagree in practice: if you have things like "X minutes ago" text or "weather in the past 5 minutes" etc, then it makes total sense that the page cache should be refreshed as well.

No, that is actually not the case. […]

Sorry, I misphrased. I wanted to say: "The maximum age you configure on the performance settings page is only set when internal page caching is enabled!". Of course it happens on both cache misses and cache hits.

Regarding the new proposal: I like it very much.

Yay :)

Setting Cache-Control: max-age is not only necessary for turning on the browser cache but also for operation behind a reverse proxy. This should be specified more explicit.

While it's true that that's also relevant/applicable to reverse proxies, I think that "reverse proxy" is too scary for "the 90%". Those who use a reverse proxy will surely already understand this, without needing that to be called out specifically. That's why I omitted it.

Any other thoughts for the new proposal?

znerol’s picture

Maybe this could work in the description text:

The maximum time a page may be cached by a browser or a proxy server.

Wim Leers’s picture

#17: Sounds good.

Anything else?

znerol’s picture

Anything else?

A patch to review? :)

nielsvm’s picture

I'm *big favor* of getting this in, we should better protect our users against the tight relation between these two settings. Hopefully that will also reduce the amount of sites running without internal page caching that don't have a internal cache/rproxy in front of them. This often fuels competitors with the "Drupal is slow" argument so moving more towards "fast by default" (or almost default with hiding the checkbox at none) is better.

I've been testing #2124957 and related sub issues recently and with that shaping well up this is all becoming more and more important, as the internal page cache will be "less in the way" and less of a irritation to site users but something that just works and should be enabled as much as possible.

Niels

Wim Leers’s picture

Title: Hide the "Use internal page cache" checkbox unless page caching is enabled » Simplify performance settings page
Issue tags: -sprint

This is not a focus issue, so untagging "sprint". We have higher priority things to deal with first.

znerol’s picture

LewisNyman’s picture

Issue tags: +frontend
moshe weitzman’s picture

Assigned: Wim Leers » Unassigned

Open for anyone to move ahead as Wim has other focus issues these days.

znerol’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

External cache (adding Cache-Control header) is now separated from the internal cache, see #2257709: Remove the interdependence between the internal page cache and management of the Cache-Control header for external caches. The settings should be updated to reflect this.

jhedstrom’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
800 bytes

Reroll of #1.

Berdir’s picture

Berdir’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
61.16 KB

This is how the page looks now.

No idea if there's still something to simplify or improve?

Berdir’s picture

Wim Leers’s picture

msonnabaum’s picture

I tried to read up on this issue (since I was the one who made the change being objected to here), but this issue is all over the place now. Maybe someone could start a new, more focussed issue for the problem being solved and proposed solution?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

I think there is still stuff to do here. The description which says

Note: Drupal provides an internal page cache module that is recommended for small to medium-sized websites.

is largely irrelevant because this setting has nothing to do with that. It only affects the headers that are outputted from Drupal. Additionally we have a clash of terminology because we're setting the

Page cache maximum age

value and this has nothing to do with the internal page cache module.

alexpott’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
3.99 KB
141.72 KB

Here's a patch that changes the Page cache title to

Browser and proxy cache maximum age

so there can be no confusion and only displays something about the Internal Page Cache module if it is not installed.

Link to screenshot of what it now looks like when page_cache is not installed: https://www.drupal.org/files/issues/2018-03-12/Screen%20Shot%202018-03-1...

borisson_’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update
FileSize
123.55 KB
121.18 KB
112.38 KB

Updated the Issue summary.

This is the current page:

This is how it looks after the patch is applied

With the page cache module enabled.

With the page cache module not installed.

alexpott’s picture

@borisson_ I think you might have the

With the page cache module enabled.

and

With the page cache module not installed.

images around the wrong way.

borisson_’s picture

#40, I did! Thanks! Sorry. Edited the comment to fix the order.

catch’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Reviewed & tested by the community » Fixed

Nice to see small UI cleanups like this happening.

Committed 2f1a5b3 and pushed to 8.6.x. Thanks!

  • catch committed 4e43216 on 8.6.x
    Issue #2216161 by Wim Leers, alexpott, jhedstrom, borisson_, Berdir:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.