diff --git a/src/docs/markdown/caddyfile/patterns.md b/src/docs/markdown/caddyfile/patterns.md index adcba9c..0e858ee 100644 --- a/src/docs/markdown/caddyfile/patterns.md +++ b/src/docs/markdown/caddyfile/patterns.md @@ -241,6 +241,15 @@ example.com { } ``` +If your `index.html` is static, you may want to consider adding a `Cache-Control` header to instruct clients to cache it. Since the `try_files` rewrite is used to serve it from other paths, you can wrap the `try_files` with a `route` so that the `header` handler runs after the rewrite (it normally would run before due to the [directive order](/docs/caddyfile/directives#directive-order)): + +```caddy-d +route { + try_files {path} /index.html + header /index.html Cache-Control "public, max-age=0, must-revalidate" +} +``` + ## Caddy proxying to another Caddy