As suggested by @WimLeers on #2888838: Optimize render caching, the render cache contains both data for the internal page cache and for the rest of the render cache mechanism, with different patterns of use and lifetime.

As such, it would make sense to allow splitting the page cache to a different bin.

Another big chunk of the render bin is about entity views which, as @Catch mentions, tend to be used only on one page at least in full mode, so maybe these could be moved there too.

Comments

fgm created an issue. See original summary.

fgm’s picture

wim leers’s picture

Status: Active » Needs review
Issue tags: +DX (Developer Experience)
StatusFileSize
new924 bytes

Status: Needs review » Needs work

The last submitted patch, 3: 2889603-3.patch, failed testing. View results

catch’s picture

Big +1 on this, it'll help mitigate some of the trade-offs in #2526150: Database cache bins allow unlimited growth: cache DB tables of gigabytes! as well.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new2.66 KB
new3.51 KB

Status: Needs review » Needs work

The last submitted patch, 6: 2889603-6.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new2.97 KB
new6.46 KB

Status: Needs review » Needs work

The last submitted patch, 8: 2889603-8.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new992 bytes
new7.07 KB

Status: Needs review » Needs work

The last submitted patch, 10: 2889603-10.patch, failed testing. View results

znerol’s picture

Very much in favor of splitting up the bins again. I honestly have no idea what the reason was to combine render cache and page cache in the first place.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new748 bytes
new7.43 KB

This should be green now.

fgm’s picture

StatusFileSize
new2.71 KB
new9.69 KB

Seems so clean...I think we should also be flushing this bin in PerformanceForm::submitForm() along with the render cache ? I'm rerolling with this addition. Actually, do we even need to actually flush the render cache any longer in that case ?

Also a tiny style question:

  1. +++ b/core/modules/block/src/Tests/BlockTest.php
    @@ -379,7 +379,7 @@ public function testBlockCacheTags() {
    +    $cache_entry = \Drupal::cache('page_cache')->get($cid);
    

    Any reason it's not being injected ? (same question all along)

catch’s picture

Very much in favor of splitting up the bins again. I honestly have no idea what the reason was to combine render cache and page cache in the first place.

We never had a dedicated render_cache bin, so render cached items (in 7.x) tended to end up in cache or cache_block depending on what was specified in the render array. In 8.x we renamed cache_page to cache_render to include those items (since it's a cache of rendered HTML), but that was long before we enabled render caching by default.

Why cache.page_cache and not cache.page?

fgm’s picture

StatusFileSize
new9.61 KB
new9.7 KB

Updated to used cache.page as per @Catch in #15.

wim leers’s picture

StatusFileSize
new3.57 KB
new10.43 KB

#14: hah, nice catch! So this is why (quoting HEAD):

    // This form allows page compression settings to be changed, which can
    // invalidate cached pages in the render cache, so it needs to be cleared on
    // form submit.
    $this->renderCache->deleteAll();

Page Cache used to store its cache items in the render cache bin, now it stores it in the page_cache cache bin. So #14 is changing too much; rather than adding a new thing to clear, it should be updating which thing is being cleared.

Furthermore… #2775381: response.gzip is redundant and should be removed just landed. Which means we don't have any of this "page compression" stuff anymore. So it's completely obsolete. #2775381 failed to remove it because… there was zero test coverage for this.

Fixed :)

To answer your question about injection: that's pure refactoring, it's out of scope for this issue. Would be great to clean up in another issue. The only reason AFAIK: legacy tests.


#15: Hah, awesome catch!


I think this is ready now.

wim leers’s picture

Status: Needs review » Needs work

The last submitted patch, 17: 2889603-17.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new709 bytes
new10.37 KB

Oops.

fgm’s picture

Indeed, I had confused the "clear" button and the main submit, which doesn't need the invalidation. Looks good to me.

dawehner’s picture

I'm curious here, wouldn't page_cache_maximum_age theoretical requires page cache changes, when you lower the amount of time we store page cache entries? Maybe this is just a super edge case so its not worth carrying about it though.

fgm’s picture

@dawehner, do you mean like changing the expiration on items in the cache bin to limit it to the computed timestamp under page_cache_maximum_age, for those which are not set to Cache::PERMANENT (e.g. (site):/403:html) ? That would make sense, since it was actually implemented previously by the flush of the cache applied to the compressing variation, but no longer exists here.

wim leers’s picture

#22: I think that makes sense, but it's out of scope here. We're just moving things to a different cache bin here :)

dawehner’s picture

Well, maybe I just don't get why it is in scope to remove the cache clearing then :(

wim leers’s picture

StatusFileSize
new3.09 KB

You're right, it isn't. @fgm's changes in #14 triggered that. Reverted all changes in PerformanceForm.

Created #2892179: Follow-up for #2775381: clearing render cache in PerformanceForm::submitForm() is obsolete for this.

wim leers’s picture

StatusFileSize
new7.35 KB

Oops.

dawehner’s picture

For behaviour equality, shouldn't we clear now both buckets?

wim leers’s picture

I think you mean not only

    $this->renderCache->deleteAll();

but also

    $this->pageCache->deleteAll();

?

That's exactly what @fgm did in #14 and I explained in #17 why that is not necessary. We now have #289179: Idea, need input : Book review rating system to remove $this->renderCache->deleteAll();.

If that's not what you meant, can you please clarify?

dawehner’s picture

Well, I still think about the max age time bit.

znerol’s picture

I think @dawehner has a point here. This is not only about max-age but also js and css aggregation settings which affect all (cached) pages. Hence I'd rather leave that piece of code in there and just swap out the bin.

We can continue the bikeshed about whether or not it is necessary to flush the page cache in #2892179: Follow-up for #2775381: clearing render cache in PerformanceForm::submitForm() is obsolete.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good I think, surprisingly small patch, nice.

Although we possibly want to do a cache record for this, in case people (incorrectly) the render cache bin directly or something like that?

I'm also pretty sure we had existing issues about having a way to separate the page cache from other render caches, e.g. with a special cache tag, but can't find them right now. I think that's no longer necessary now.

berdir’s picture

One thing on the cache bin name, though.

cache.page_cache is a bit repetitive, but it is a) the module name/namespace and b) would be consistent with cache.dynamic_page_cache. Thoughts?

fgm’s picture

Well, since you ask for thoughts, the module machine_name is indeed page_cache, but for most people, it is "internal page cache", which is rather unclear to people not looking into the implementation, since DPC is also in core (both are internal to core).

Having the modules and its newly dedicated bin named "anonymous page cache" would probably make more sense from an Admin eXperience PoV.

catch’s picture

Status: Reviewed & tested by the community » Fixed

I didn't even think about it being the same as the module name, I guess because it's Internal Page Cache in the UI. So... I think it's OK to go in as cache.page.

@fgm's idea is a good one on a wider rename.

Committed 9fa0f16 and pushed to 8.4.x. Thanks!

anavarre’s picture

9fa0f16 returns a bad object and I'm not seeing the commit in Git either. Did you actually push this?

  • catch committed 687d4cf on 8.4.x
    Issue #2889603 by Wim Leers, fgm: Split the internal page cache from the...
wim leers’s picture

@fgm++
@catch++

wim leers’s picture

Issue tags: +8.4.0 release notes

This actually makes DX so much better depending on what kind of site it is, that it's probably worth a mention in the release notes?

fgm’s picture

Or a change record ? Providing a hint regarding the relative sizes expected for the new bin vs the older one would be nice, because people using size-limited caches like memcache need to know what to allocate for the new bin, aka what to remove from the previous render bin allocation.

catch’s picture

Issue tags: +Needs change record

Yes it's not an API change, but it's worth an informational change record for site admins who might want to tweak memcache allowances and a release notes mention.

mpdonadio’s picture

fgm’s picture

The CR should mention the recommendations about bin allocation as mentioned in #40 / #41.

berdir’s picture

Added a sentence about that, but I think that's going to vary heavily on the specific site as I commented. You're welcome to edit if you have a better idea on how to write that. Published.

fgm’s picture

I think it's probably the most one can safely say on the topic, indeed.

Status: Fixed » Closed (fixed)

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