Skip to content

Return null duration instead of default from stopCollectingCacheInfo - #18199

Draft
timkelty wants to merge 1 commit into
6.xfrom
feature/element-cache-default
Draft

Return null duration instead of default from stopCollectingCacheInfo#18199
timkelty wants to merge 1 commit into
6.xfrom
feature/element-cache-default

Conversation

@timkelty

Copy link
Copy Markdown
Contributor

Description

If something calls stopCollectingCacheInfo, there is no way to know if the elements had a duration, or if the default duration from config was used.

This moves the application of the default to \craft\services\TemplateCaches::endTemplateCache.

Use-case

Craft Cloud uses \craft\services\Elements::stopCollectingCacheInfo to collect tags and expiry for static cache. It has it's own default for static cache (1 year), but because a duration is always returned (even if it is just the default config fallback), there isn't a way to know if it actually came from an element.

Notes

To avoid this kind of thing, future versions should separate cache duration settings by use-case, e.g. templateCacheDuration, instead of sharing one config value.

@brandonkelly
brandonkelly changed the base branch from 4.x to 6.x December 28, 2025 17:38
@brandonkelly

Copy link
Copy Markdown
Member

This is a breaking change, so retargetted to 6.x.

@brandonkelly
brandonkelly marked this pull request as draft August 4, 2026 15:51
@craftcms craftcms deleted a comment from github-actions Bot Aug 4, 2026
@brandonkelly
brandonkelly force-pushed the feature/element-cache-default branch from 841e192 to 754a499 Compare August 4, 2026 15:51
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