Closed (fixed)
Project:
EU Cookie Compliance (GDPR Compliance)
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Nov 2018 at 17:04 UTC
Updated:
15 Jul 2025 at 04:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
svenryen commentedGreat idea. I'd love to see some better caching.
Just to understand the implications of the slowdown. Did you check whether the caching situation improves when the Internal Dynamic Page Cache or Internal Page Cache are enabled?
In D7, we're storing a cache item with all the settings, including the rendered templates. Do you think that's a good approach, or does D8 have something better to offer?
Comment #3
berdir> Just to understand the implications of the slowdown. Did you check whether the caching situation improves when the Internal Dynamic Page Cache or Internal Page Cache are enabled?
Once cached it should be fine. But since it is a top-level element and not a block or so, it needs to be recalculated for every page * cache context variations (e.g. each set of user permissions).
I would need to check if the render cache/lazy builder could be used, it would need to refactored a bit I guess. If we would manage that, it could even be a possibility to auto-placeholder the whole thing.
Comment #4
svenryen commentedTake a look at the D7 codebase. Around line 135 we have some caching that seems to do the job. Maybe something similar can be achieved in D8? I didn't do the initial port, so I don't know why the caching was removed.
Comment #5
berdirHad another look, I think reusing render caching would be quite tricky, so I just did some custom caching, did not test this at all, so it's most likely broken ;)
Comment #7
svenryen commentedThanks for the patch. Sorry that we don't have tests :)
The cid needs to also factor in the theme and the the active domain if the domain module is enabled.
Comment #8
svenryen commentedThe patch also needs a re-roll against latest -dev.
Comment #9
mirakolous commentedI have re-rolled this patch to work with the latest dev. I have also added the active domain and theme in the cache tag string. I did not test the domain portion of this so we would definitely want to test that or remove that before patching dev.
Comment #10
mirakolous commentedComment #11
svenryen commentedThanks. I'll have a look.
Comment #12
Pascal- commentedComment #13
svenryen commentedThe proposed patch didn't apply cleanly. Here's an updated patch.
Comment #14
svenryen commentedWhen the domain module is available, we also need to check if there are domains configured, or else the call to
\Drupal::service('domain.negotiator')->getActiveId()fails. This can be resolved by checkingcount(Domain::loadMultiple()).Here's an updated patch that resolves that issue and also re-rolls the rest of the changes against the latest -dev.
Would be nice if somebody can review the patch.
Comment #15
neslee canil pinto@svenryen patch is not getting applied. Needs a re-roll against the latest dev.
Comment #16
suresh prabhu parkala commentedRe-rolled patch please review!
Comment #18
svenryen commentedComment #19
svenryen commentedComment #20
maximpodorov commentedThe patch for 8.x-1.9 release is the copy of #13 patch adapted to renamed configuration variables (#2969161: Form technical names mixed up for labels?).
Comment #21
svenryen commented@maximpodorov, the patch in #20 won't apply. Would you be able to make a patch against the latest -dev?
Comment #22
suresh prabhu parkala commentedRe-rolled patch, please review
Comment #24
svenryen commentedComment #25
svenryen commentedWe can't use the patch from #22. It misses the fix from #14, where
\Drupal::service('domain.negotiator')->getActiveId()was added to fix a fatal crash. I see the code was dropped in #20Can you please make sure you don't leave out any code from the previous patches when you re-roll?
Also, there are code styles to fix. See the diff in #23.
Comment #26
svenryen commentedThe patch also doesn't pick up on the many changes that's been made to the code base since #13, I'm fixing that now.
Comment #27
svenryen commentedHere's a patch that resolves all the issues with #22
Comment #28
svenryen commentedHere's an interdiff for information.
Comment #29
neslee canil pinto#27 looks good to me. Moving to RTBC.
Comment #31
svenryen commentedComment #32
svenryen commentedComment #34
pianomansam commentedWhy can't we use render cache? The three existing parts of the $cid (language ID, domain ID, theme name) are already covered by the render cache. In fact, having to add info from another module, the domain module, is a code smell that perhaps this isn't the best approach. The domain module's documentation suggests users add the
url.sitecache context so that the cache can vary based on the domain. So the EU Cookie Compliance module shouldn't need to worry about the domain. However, because it micromanages this part of the renderable content, it needs to account for all the ways it may vary.In working on the #3480626: DNT (Do Not Track) header detection not working when caching enabled bug, I traced the issue to the custom cache entry's $cid not varying based on the DNT header. If a custom cache entry was not deployed, that bug would easily be fixed with one line of code adding the DNT header to the cache context. Instead, we need yet another variance of the $cid.
So to summarize, why can't we let the render cache do its job? Micromanaging a separate cache entry causes additional complexity, makes it easier to cause bugs (DNT header issue), and causes this module to care about unrelated modules (domain module).
Comment #35
svenryen commentedReopening this issue after comment from @pianomansam.
Comment #36
atowl commentedhi @pianomansam
How much of this change are we talking about undo'ing?
Comment #37
pianomansam commented@atowl the merge request on #3480626: DNT (Do Not Track) header detection not working when caching enabled does what I propose (removing the custom cache entry). The only line of code that adds the DNT header is the cache context addition.
Comment #38
atowl commentedHi @pianomansam,
So given that line is in the request of #3480626, we could close this issue and merge that instead?
Comment #39
pianomansam commented@atwol yes, you absolutely could. However, I wanted to point out that #3480626 undoes much of the work done in this issue.
Comment #40
atowl commentedOK thanks for the information @pianomansam,
I'll (re) close this as fixed, and i'll look at merging #3480626, and any further disucussion in that thread.