Skip to content

[5.x] Add --header option to static warm command #11763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from

Conversation

ChristianPraiss
Copy link
Contributor

@ChristianPraiss ChristianPraiss commented May 5, 2025

Add support for custom headers in static:warm command

This PR introduces a new --headers option to the static:warm command, allowing users to specify custom HTTP headers for requests made during cache warming, e.g. for:

  • Pages requiring authentication or API tokens for access.
  • Need to trigger static cache refreshes even when static files are being served, using custom server rules. Especially useful for zero-cache-downtime scenarios

Related docs here: statamic/docs#1674

@ChristianPraiss ChristianPraiss force-pushed the feat/static-warm-headers branch from 32d9c3b to b4df7c8 Compare May 5, 2025 10:56
@jasonvarga jasonvarga changed the title [5.x] Add --headers option to static warm command [5.x] Add --header option to static warm command May 14, 2025
Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

The test was nice, thanks! But there was a false positive.

Since you can't pass an array from the CLI (but you can in the test), you need to use the option multiple times as you noted. But, you need to define it in the signature with an asterisk. Running the command from the CLI the way you had it only used the first one you passed in.

Also, since you need to use the option multiple times, and each time it's a singular header, I've changed the option from headers to header.

please static:warm --header="Foo: Bar" --header="Bar: Baz"

@ChristianPraiss
Copy link
Contributor Author

Always happy to help!

Good to know that, thx for noticing and fixing it right away! The intricacies of artisan commands...

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