Add support for configuring immutable paths
All checks were successful
Build / build (push) Successful in 2m38s

This commit is contained in:
Moritz Ruth 2025-03-02 17:12:20 +01:00
parent 11ed96b683
commit 5fff414805
Signed by: moritzruth
GPG key ID: C9BBAB79405EE56D
2 changed files with 16 additions and 0 deletions

View file

@ -83,6 +83,20 @@ impl CaddyController {
})); }));
} }
if !config.immutable_paths.is_empty() {
routes_array.push(json!({
"match": [{ "path": config.immutable_paths }],
"handle": [{
"handler": "headers",
"response": {
"set": {
"Cache-Control": ["public, max-age=15778476, immutable"]
}
}
}]
}))
}
routes_array.push(json!({ routes_array.push(json!({
"handle": [{ "handle": [{
"handler": "file_server", "handler": "file_server",

View file

@ -23,6 +23,8 @@ pub struct SiteConfig {
pub paths_mode: SiteConfigPathsMode, pub paths_mode: SiteConfigPathsMode,
#[serde(default)] #[serde(default)]
pub redirects: Vec<SiteConfigRedirect>, pub redirects: Vec<SiteConfigRedirect>,
#[serde(default)]
pub immutable_paths: Vec<String>,
} }
#[derive(Deserialize, Default, Eq, PartialEq)] #[derive(Deserialize, Default, Eq, PartialEq)]