Skip to content

[6.x] Fix half measure static cache serving pages missing from the URL index - #15914

Open
duncanmcclean wants to merge 1 commit into
6.xfrom
fix-orphaned-static-cache-responses
Open

duncanmcclean wants to merge 1 commit into
6.xfrom
fix-orphaned-static-cache-responses

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where, with the half measure strategy, a page cached while a flush or invalidation was running would stay cached, and no later invalidation could clear it.

This was happening because the ApplicationCacher forgot responses before their URL index entries, and tracked URLs before their responses were stored. A visitor re-caching a page in between would leave its response stored, but its URL missing from the index, so flush(), invalidateUrl() and invalidateUrls() could never reach it again.

This PR fixes it by making sure a stored response never outlives its index entry:

  • flush() now reads every domain's keys and forgets the URL indexes inside the URLs lock, then forgets the responses. A page re-cached during the loop lands on a fresh index.
  • invalidateUrl() and invalidateUrls() now forget the index entries before the responses.
  • cachePage() now tracks the URL once its response has been stored. If an invalidation runs in between, the worst case is an index entry without a response, which just costs a render.

Amp thread: https://ampcode.com/threads/T-bc731ecc-5236-4cea-8cc5-ad26e5469665

Fixes #15912

This branch has not been deployed

No deployments
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.

Half static cache: a page re-cached during a flush or invalidation stays cached, and no later invalidation clears it

2 participants