cloudflare / templates

A collection of starter templates and examples for Cloudflare Workers and Pages
https://cloudflareworkers.com
MIT License
999 stars 632 forks source link

Cache variants for certain cookies #48

Closed fabian-barney closed 1 year ago

fabian-barney commented 4 years ago

Problem: Cookie banners that are common for legal reasons store the visitors consent in cookies. These cookies may contain complex options the visitor has choosen or a simple true/false for consent.

We need different cached versions of the same URL for each variant of that cookie. And another version when it is completly unset.

Without caching all these different versions by cookie content the caching becomes really pointless.

Current caching strategies lead to unlawful behaviour in the following case:

  1. purge all cloudflare caches
  2. user #1 requests page 1; page 1 shows cookie banner; page 1 is cached
  3. user #1 gives cookie consent; cookie is set
  4. user #1 requests page 2; page 2 does NOT show cookie banner, because of the consent-cookie; page 2 IS CACHED WITHOUT COOKIE BANNER
  5. user #2 requests page 2; page 2 does NOT show cookie banner; the CACHED version of page 2 got delivered; the CACHED version depends on consent which user #2 had never given
ericger commented 4 years ago

Oh I just saw, that this post is from 2019! Are there any news to this issue?

If the Cookie Plugin is added externally, would it be still a problem?

lauragift21 commented 1 year ago

Hi @fabian-barney, following up to see if this is still an issue that needs to be addressed. This repo is now moved to the workers-sdk monorepo where the templates live: https://github.com/cloudflare/workers-sdk/tree/main/templates

I'll close out this one but feel free to reopen it in the workers-sdk repo if the issue still needs to be addressed.