[6.x] Fix: statamic:static:warm drops --header values on paginated pages - #15278
Open
steveparks wants to merge 3 commits into
Open
[6.x] Fix: statamic:static:warm drops --header values on paginated pages#15278steveparks wants to merge 3 commits into
statamic:static:warm drops --header values on paginated pages#15278steveparks wants to merge 3 commits into
Conversation
`statamic:static:warm` attaches `--header` values to its main request pass:
```php
// requests(), line ~221
return new Request('GET', $uri, $headers);
```
but `warmPaginatedPages()` — which follows an index page's `X-Statamic-Pagination` header to warm pages 2..n — builds its requests without them:
```php
// warmPaginatedPages(), line ~136
$requests = $urls->map(fn (string $url) => new Request('GET', $url))->all();
```
So a warm run with `--header "X-My-Token: …"` identifies `/tags` to whatever is in front of the origin and does **not** identify `/tags?page=2`. Anything keyed on that header — a CDN/WAF skip rule, an origin allowlist, basic-auth-by-header on a staging site — applies to page 1 of every paginated URL and nothing else.
This is invisible until the thing in front of the origin starts acting on unidentified traffic, at which point every paginated page silently fails to cache while the command still reports success (the follow-up pool's rejections are printed, but see the second bug below, which makes them name the wrong URL).
In my case, on a site behind Cloudflare with a skip rule matching the warm's header: in a 15-hour window where bot protection was challenging automated traffic, the origin's own warm took 1,782 managed challenges against 4,191 skips — one client, one user-agent, split purely by whether a request was a pagination follow-up. Guzzle cannot pass a managed challenge, so none of those pages entered the cache.
### The fix
Parse the headers the same way the main pass does and pass them into the paginated requests.
### Notes
- No behaviour change for anyone not passing `--header`.
statamic:static:warm drops --header values on paginated pagesstatamic:static:warm drops --header values on paginated pages
Contributor
Author
|
My first fail was the title - have fixed that. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

statamic:static:warmattaches--headervalues to its main request pass:but
warmPaginatedPages()— which follows an index page'sX-Statamic-Paginationheader to warm pages 2..n builds its requests without them:So a warm run with
--header "X-My-Token: …"identifies/tagsto whatever is in front of the origin and does not identify/tags?page=2. Anything keyed on that header (eg a CDN/WAF skip rule, an origin allowlist, basic-auth-by-header on a staging site) applies to page 1 of every paginated URL and nothing else.The fix
Parse the headers the same way the main pass does and pass them into the paginated requests.
No behaviour change for anyone not passing
--header.Note
I'm an inexperienced contributor. I've tried to make sure I follow the contributor guide, but please do point out anything I missed or could improve on.