You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/collections/docs/static-caching.md
+42-1Lines changed: 42 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -244,6 +244,12 @@ The `static:warm` command supports various arguments:
244
244
For example with `--max-depth=1` it will visit pages like `/about` and `/products` but not `/products/cool-new-shoes-1` or `/any/other/path/that/is/too/deep`.
245
245
***`--max-requests`**
246
246
Limits the number of requests made by the command. Likely makes the most sense to be used alongside the `--uncached` option.
247
+
***`--header`**
248
+
Allows you to specify custom HTTP headers to be sent with each request. Can be used multiple times to set multiple headers. Useful for APIs, protected routes, or any scenario where custom headers are required.
249
+
250
+
For example: `--header="Authorization: Bearer your_token" --header="X-Ignore-Cache: true"`
251
+
252
+
You can find [practical examples](#custom-headers) of this parameter below.
247
253
248
254
Depending on your site's setup, it might be a good idea to add this command to your deployment script.
249
255
@@ -327,6 +333,41 @@ class AppServiceProvider
327
333
}
328
334
```
329
335
336
+
### Custom headers
337
+
338
+
The `--headers` option can be used in advanced scenarios to control how the static cache is warmed. Here are some practical examples:
339
+
340
+
#### Bypassing cache for refreshes with Nginx
341
+
342
+
If you have custom Nginx rules, you can check for a specific header (e.g., `X-Cache-Refresh: 1`) and bypass the `try_files` static cache, forcing a fresh request to the backend. For example:
343
+
344
+
```nginx
345
+
location / {
346
+
if ($http_x_cache_refresh = "1") {
347
+
proxy_pass http://127.0.0.1:8000; # your statamic server
If your site is protected by HTTP authentication or expects a specific header, you can use `--header` to provide the necessary credentials or tokens so the warm requests are not blocked. For example:
0 commit comments