Skip to content

Commit a83077e

Browse files
authored
Fix: statamic:static:warm drops --header values on paginated pages
`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`.
1 parent 59b5080 commit a83077e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/Console/Commands/StaticWarm.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ private function warmPaginatedPages(string $url, int $currentPage, int $totalPag
133133
return $url;
134134
});
135135

136-
$requests = $urls->map(fn (string $url) => new Request('GET', $url))->all();
136+
$headers = $this->parseHeaders($this->option('header'));
137+
138+
$requests = $urls->map(fn (string $url) => new Request('GET', $url, $headers))->all();
137139

138140
$pool = new Pool($this->client(), $requests, [
139141
'concurrency' => $this->concurrency(),

0 commit comments

Comments
 (0)