_headers file in the repository’s root directory, Sevalla will parse the file’s contents and apply the custom header rules to matching responses.
Header rule format and examples
Each header rule starts with a path on its own line, followed by one or more indented header definitions in the formatHeader-Name: value. Any line beginning with # will be treated as a comment and ignored. Paths are case-sensitive.
For example:
Applying headers to all pages
Use the/* wildcard pattern to set headers that apply across your entire site:
Wildcards
An asterisk (*) represents a wildcard, which matches any characters in a path, including slashes. For example:
Cache-Control header to any path under /images/, such as /images/logo.png or /images/icons/arrow.svg.
You can also use wildcards within a path segment to match file extensions:
Note: Wildcards are greedy -/*.svgwill match both/logo.svgand/images/icons/logo.svg, as the wildcard crosses directory boundaries.
Placeholders
You can use placeholders to match a single path segment. A placeholder starts with: followed by a name and matches any characters except /. For example:
/docs/v2/getting-started or /docs/v3/api-reference, but not /docs/ by itself.
Combining multiple rules
When multiple rules match a request path, all of their headers are applied to the response. If the same header name appears in more than one matching rule, the values are combined with a comma separator. For example:/api/users matches both rules. The resulting headers would be:
Cache-Control: public, no-storeX-Custom: globalX-Api: true
Cache-Control values between wildcard and specific rules.
Common use cases
Security headers
Caching static assets
Custom headers for an API path
CORS for font files
Restricted headers
Certain headers are managed by the platform and cannot be overridden. If a restricted header appears in your_headers file, it will be silently ignored. The following headers are restricted:
Accept-RangesAgeAllowAlt-SvcConnectionContent-EncodingContent-LengthContent-RangeDateLocationServerTrailerTransfer-EncodingUpgrade