Skip to content

[6.x] Keep view shared data dynamic within nocache tags - #15928

Merged
duncanmcclean merged 1 commit into
6.xfrom
nocache-shared-view-data
Nov 16, 2026
Merged

duncanmcclean merged 1 commit into
6.xfrom
nocache-shared-view-data

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where variables shared with View::share() would always output their cached value inside {{ nocache }} tags, rather than their value on the current request.

This was happening because nocache regions store the context they need, minus anything that's already in the cascade, since the cascade gets rebuilt fresh on each request. View shared data isn't part of the cascade, so it was getting stored with the region. When the region was rendered again, that stale value was passed as view data, which takes precedence over Laravel's freshly shared data.

This PR fixes it by including view shared data alongside the cascade in the nocache session, so it gets filtered out of the region's context like any other top-level variable.

Fixes #10651

Amp thread: https://ampcode.com/threads/T-1fd64e48-b1e3-4e07-8b4a-fc4dfcbe86c3

@duncanmcclean
duncanmcclean merged commit 933c7a3 into 6.x Nov 16, 2026
65 checks passed
@duncanmcclean
duncanmcclean deleted the nocache-shared-view-data branch November 16, 2026 16:49
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.

nocache tag and view::shared variables does not work "well"

2 participants