Problem/Motivation

We have the session cache context in core, to vary something per session. A related, but far less specific and therefore better cacheable variant of that is to vary something per "session or not". (This is a boolean.)

We need this for BigPipe: #2469431-198: BigPipe for auth users: first send+render the cheap parts of the page, then the expensive parts.

A similar one is user vs. user.is_super_user: the former has many, many possible values, the second is a boolean.

Proposed resolution

Add session.exists cache context.

Remaining tasks

  1. Code.
  2. Test coverage.
  3. Review.
  4. RTBC.
  5. Commit.
  6. Update https://www.drupal.org/developing/api/8/cache/contexts.

User interface changes

None.

API changes

API addition: new session.exists cache context.

Data model changes

None.

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Title: Add SessionExistsCacheContext » Add SessionExistsCacheContext ('session.exists')
Assigned: wim leers » Unassigned
Status: Active » Needs review
Issue tags: +API addition
StatusFileSize
new7.23 KB
wim leers’s picture

Issue summary: View changes
wim leers’s picture

+++ b/core/core.services.yml
@@ -55,6 +55,11 @@ services:
+      - { name: cache.context}

Nit: missing a space.

(I'll fix this after others have reviewed this, or a committer could also fix this on commit.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC - Looks great to me :)

  • catch committed 4a67b9d on 8.1.x
    Issue #2671988 by Wim Leers: Add SessionExistsCacheContext ('session....
catch’s picture

Status: Reviewed & tested by the community » Fixed

I wasn't sure about the naming here, but all the other options are worse (like HasSession etc.). Committed/pushed to 8.1.x, thanks!

wim leers’s picture

alexpott’s picture

wim leers’s picture

RTBC'd :)

Status: Fixed » Closed (fixed)

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