Skip to content

Add cache_tracker tag#39

Merged
ryanmitchell merged 1 commit into
thoughtco:mainfrom
aerni:feature/cache-tracker-tag
Jun 16, 2026
Merged

Add cache_tracker tag#39
ryanmitchell merged 1 commit into
thoughtco:mainfrom
aerni:feature/cache-tracker-tag

Conversation

@aerni

@aerni aerni commented Jun 16, 2026

Copy link
Copy Markdown

Adds a {{ cache_tracker }} tag for registering a tracked tag directly from a view, instead of rendering an empty dummy partial just to trigger the partial hook.

{{ cache_tracker tag="page_builder:projects_latest" }}

{{# or as the tag itself #}}
{{ cache_tracker:page_builder:projects_latest }}

This is useful, for example, for a projects block with two modes. A latest mode pulls the newest entries via a {{ collection }} query, so its output depends on the collection's order. A selection mode uses hand-picked entries. Tracking only the latest variant previously meant a dummy partial. Now it's inline:

{{ if block:query == 'latest' }}
    {{ cache_tracker tag="page_builder:projects_latest" }}
{{ /if }}

The latest variant gets its own tag so it can be invalidated on its own in a CollectionTreeSaved listener when the collection is reordered, while selection blocks stay cached.

@ryanmitchell

Copy link
Copy Markdown
Contributor

Nice idea, I should have thought of this!

@ryanmitchell ryanmitchell merged commit 4fe5d75 into thoughtco:main Jun 16, 2026
2 checks passed
@aerni aerni deleted the feature/cache-tracker-tag branch June 16, 2026 10:56
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.

2 participants