Skip to content

Add element-level opt-out for page caching#3980

Open
robinboening wants to merge 1 commit into
AlchemyCMS:mainfrom
robinboening:feature_element_level_page_cache_optout
Open

Add element-level opt-out for page caching#3980
robinboening wants to merge 1 commit into
AlchemyCMS:mainfrom
robinboening:feature_element_level_page_cache_optout

Conversation

@robinboening

Copy link
Copy Markdown
Contributor

Closes #3973.

This adds a page_cache option to element definitions, allowing individual elements to opt a page out of HTTP page caching:

- name: restricted_downloads
  page_cache: false

When a page contains, or can render, an element definition with page_cache: false, Alchemy now renders the page instead of relying on conditional page-cache revalidation. This lets dynamic or permission-sensitive elements execute and apply their own fragment cache keys.

The opt-out uses Cache-Control: no-store rather than no-cache, because no-cache may still allow stored responses to be revalidated and return 304, which would skip rendering the element entirely.

The option defaults to true and is kept as definition-only metadata, so existing element definitions and page cache behavior remain unchanged unless an element explicitly opts out.

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@robinboening robinboening requested a review from a team as a code owner June 17, 2026 16:51
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.12%. Comparing base (6b057d9) to head (19a8a0b).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3980   +/-   ##
=======================================
  Coverage   98.12%   98.12%           
=======================================
  Files         346      346           
  Lines        8971     8980    +9     
=======================================
+ Hits         8803     8812    +9     
  Misses        168      168           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robinboening robinboening force-pushed the feature_element_level_page_cache_optout branch from 834ae20 to 19a8a0b Compare June 17, 2026 20:48
Allow element definitions to declare page_cache: false so pages that contain or can render those elements skip HTTP page-shell caching.

Use no-store for this opt-out because no-cache still permits stored responses and conditional revalidation, which can return 304 before element-level cache variants are rendered.

Keep the option as definition-only metadata and cover the new behavior with model and request specs.
@robinboening robinboening force-pushed the feature_element_level_page_cache_optout branch from 19a8a0b to e5c19c5 Compare June 17, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add element-level opt-out for page caching

1 participant