Skip to content

Use a unique caller reference for each invalidation - #17

Merged
bencroker merged 1 commit into
putyourlightson:developfrom
maxfenton:mf/na-unique-caller-reference
Oct 22, 2026
Merged

bencroker merged 1 commit into
putyourlightson:developfrom
maxfenton:mf/na-unique-caller-reference

Conversation

@maxfenton

@maxfenton maxfenton commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

sendRequest() sets CallerReference to time(), which repeats within a second. When two invalidations are sent in the same second, for example a refresh job and blitz/cache/purge, CloudFront rejects the second one and its paths are never invalidated:

AWS Client Error - Code: InvalidArgument - Message: Your request contains a caller reference that was used for a previous invalidation batch for the same distribution.

If the paths match, CloudFront instead returns the earlier invalidation and creates no new one, so that purge silently does nothing.

This uses StringHelper::UUID() so every request gets a unique CallerReference. The AWS SDK retries a request with the same parameters, so a retried request keeps its reference and stays idempotent.

This removes an accidental throttle: identical purges sent in the same second used to collapse into one invalidation, and now each one is sent. The throttle never worked as one, since it drops any batch whose paths differ, and its window is a fixed clock second. If throttling is wanted, it fits better in Blitz than in the purger. Blitz already merges a request's refresh data into one RefreshCacheJob at the end of the request. RefreshCacheService::refresh() could also push that job with a short delay and merge refresh data across requests, so saves close together send one invalidation with every path.

`time()` repeats within a second, so CloudFront rejects a second invalidation sent in the same second. A UUID makes each `CallerReference` unique.
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