diff --git a/README.md b/README.md index 704f13d..01b1a28 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,25 @@ docker pull ghcr.io/aliasproject/php:8.4-frankenphp Every image is configurable via environment variables — `PHP_MEMORY_LIMIT`, `PHP_OPCACHE_*`, `PHP_UPLOAD_MAX_FILESIZE`, etc. — see each Dockerfile's `ENV` block for the defaults. +## Static asset caching + +Caddy's `file_server` sends no `Cache-Control` by default, so browsers revalidate every asset on every visit and a CDN in front (Cloudflare, etc.) falls back to a short edge TTL and revalidates against the origin from every PoP. Every `frankenphp` variant can render a Caddy snippet at boot that fixes this. Nothing is emitted unless at least one path list is set, so the base image is unaffected until you opt in: + +- `CADDY_IMMUTABLE_ASSET_PATHS` — space-separated path prefixes whose files are content-hashed or carry a version in the URL (a Vite/Mix build dir, `?ver=` assets, minifier output). A change always means a new URL, so they are served with `public, max-age=31536000, immutable` (`CADDY_IMMUTABLE_ASSET_MAX_AGE`). +- `CADDY_MEDIA_PATHS` — user uploads, which keep their filename when replaced in place. Served with `public, max-age=2592000` (`CADDY_MEDIA_MAX_AGE`) so a stale copy is bounded. +- `CADDY_IMMUTABLE_ASSET_EXTENSIONS` / `CADDY_MEDIA_EXTENSIONS` — space-separated, no dots; sensible defaults for CSS/JS/fonts/images and for images/video/PDF respectively. + +`*` in a prefix matches a single path segment. The header is only applied when the file exists on disk, so 404s are never cached long-term, and HTML, PHP and JSON responses are untouched. + +```sh +# Laravel with a Vite build and user uploads on the public disk +docker run -e CADDY_IMMUTABLE_ASSET_PATHS="/build/" \ + -e CADDY_MEDIA_PATHS="/storage/" \ + ghcr.io/aliasproject/php:8.4-frankenphp +``` + +The `wordpress` variant sets both lists out of the box (see below). + ## WordPress hardening The `frankenphp:wordpress` variant renders a Caddy hardening snippet at container boot: @@ -41,3 +60,5 @@ The `frankenphp:wordpress` variant renders a Caddy hardening snippet at containe - Runs as a non-root user (UID configurable via `--build-arg APP_UID`) in group `0`. All of the above are overridable via environment variables if a site needs different values. + +The `wordpress` variant also ships defaults for the [static asset caching](#static-asset-caching) snippet covering both the Bedrock (`/app/...`, `/wp/...`) and stock (`/wp-content/...`, `/wp-includes/...`) layouts, including cache-plugin output and Avada's compiled `fusion-styles` / `fusion-scripts` directories. diff --git a/php/8.2/frankenphp/Dockerfile.wordpress b/php/8.2/frankenphp/Dockerfile.wordpress index 5a36c29..f75a0ea 100644 --- a/php/8.2/frankenphp/Dockerfile.wordpress +++ b/php/8.2/frankenphp/Dockerfile.wordpress @@ -75,6 +75,14 @@ ENV PHP_DENY_EXTENSIONS="sql sql.gz bak old log" # backup plugins need them. Add them per-site if nothing on that site does. ENV PHP_DISABLE_FUNCTIONS="exec,passthru,shell_exec,system,pcntl_exec,dl" +# Static asset caching (rendered into a Caddy snippet at boot). Covers both +# layouts. Core, plugin and theme assets carry ?ver= in their URLs, and cache +# plugins / the Avada compiler write content-hashed files, so a change is always +# a new URL: cache those for a year. Media library files keep their filename if +# replaced in place, so they get 30 days. Both are per-site overridable; "*" +# matches one path segment (multisite uploads/sites/N/). +ENV CADDY_IMMUTABLE_ASSET_PATHS="/wp/wp-includes/ /wp/wp-admin/ /app/plugins/ /app/themes/ /app/mu-plugins/ /app/cache/ /app/uploads/fusion-styles/ /app/uploads/fusion-scripts/ /app/uploads/sites/*/fusion-styles/ /app/uploads/sites/*/fusion-scripts/ /wp-includes/ /wp-admin/ /wp-content/plugins/ /wp-content/themes/ /wp-content/mu-plugins/ /wp-content/cache/ /wp-content/uploads/fusion-styles/ /wp-content/uploads/fusion-scripts/ /wp-content/uploads/sites/*/fusion-styles/ /wp-content/uploads/sites/*/fusion-scripts/" CADDY_MEDIA_PATHS="/app/uploads/ /wp-content/uploads/" + # WordPress sizing. WP_MEMORY_LIMIT is meaningless above the PHP limit, so this # must be >= whatever the site sets in wp-config/application.php. ENV PHP_MEMORY_LIMIT=512M \ diff --git a/php/8.2/frankenphp/docker-configure b/php/8.2/frankenphp/docker-configure index 4b84a10..f19693d 100644 --- a/php/8.2/frankenphp/docker-configure +++ b/php/8.2/frankenphp/docker-configure @@ -134,6 +134,67 @@ ext_alternation() { done } > "${CADDY_SITE_D}/00-hardening.caddyfile" +# --------------------------------------------------------------------------- +# Caddy cache-control snippet for static assets +# +# Only rendered when a path list is set (the base image sets none; the +# WordPress layer supplies both layouts). Two tiers: +# CADDY_IMMUTABLE_ASSET_PATHS -- prefixes whose files are content-hashed or +# carry ?ver= in their URLs (core, plugins, themes, minifier/compiler +# output). A change always means a new URL, so cache for a year. +# CADDY_MEDIA_PATHS -- media library uploads, which keep their filename when +# replaced in place. A shorter TTL bounds how long a stale copy lives. +# Both are space-separated path prefixes; "*" matches one path segment +# (e.g. /app/uploads/sites/*/fusion-styles/). Extension lists are +# space-separated without leading dots. The `file` matcher restricts the +# header to files that exist on disk, so a 404 is never cached long-term. +# Without these headers Cloudflare falls back to a short edge TTL and every +# PoP revalidates against the origin independently. +# --------------------------------------------------------------------------- + +# Space-separated path prefixes -> regex alternation. Escapes "." and "+", +# turns "*" into a single-segment wildcard. +path_alternation() { + _pattern="" + for _p in $1; do + _escaped=$(printf '%s' "$_p" | sed -e 's|[.+]|\\&|g' -e 's|\*|[^/]+|g') + if [ -z "$_pattern" ]; then + _pattern="$_escaped" + else + _pattern="${_pattern}|${_escaped}" + fi + done + printf '%s' "$_pattern" +} + +if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ] || [ -n "${CADDY_MEDIA_PATHS}" ]; then + { + if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_IMMUTABLE_ASSET_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_IMMUTABLE_ASSET_EXTENSIONS:-css js mjs woff woff2 ttf otf eot svg png jpg jpeg gif webp avif ico}") + echo "@immutable_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @immutable_assets Cache-Control \"public, max-age=${CADDY_IMMUTABLE_ASSET_MAX_AGE:-31536000}, immutable\"" + fi + + if [ -n "${CADDY_MEDIA_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_MEDIA_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_MEDIA_EXTENSIONS:-png jpg jpeg gif webp avif svg ico mp4 webm mp3 pdf woff woff2 ttf otf}") + echo "@media_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @media_assets Cache-Control \"public, max-age=${CADDY_MEDIA_MAX_AGE:-2592000}\"" + fi + } > "${CADDY_SITE_D}/10-cache-headers.caddyfile" +else + # A site that clears both lists must not inherit a stale snippet from a + # previous boot of the same container filesystem. + rm -f "${CADDY_SITE_D}/10-cache-headers.caddyfile" +fi + # --------------------------------------------------------------------------- # msmtp # --------------------------------------------------------------------------- diff --git a/php/8.3/frankenphp/Dockerfile.wordpress b/php/8.3/frankenphp/Dockerfile.wordpress index 66291b7..0d19f3e 100644 --- a/php/8.3/frankenphp/Dockerfile.wordpress +++ b/php/8.3/frankenphp/Dockerfile.wordpress @@ -75,6 +75,14 @@ ENV PHP_DENY_EXTENSIONS="sql sql.gz bak old log" # backup plugins need them. Add them per-site if nothing on that site does. ENV PHP_DISABLE_FUNCTIONS="exec,passthru,shell_exec,system,pcntl_exec,dl" +# Static asset caching (rendered into a Caddy snippet at boot). Covers both +# layouts. Core, plugin and theme assets carry ?ver= in their URLs, and cache +# plugins / the Avada compiler write content-hashed files, so a change is always +# a new URL: cache those for a year. Media library files keep their filename if +# replaced in place, so they get 30 days. Both are per-site overridable; "*" +# matches one path segment (multisite uploads/sites/N/). +ENV CADDY_IMMUTABLE_ASSET_PATHS="/wp/wp-includes/ /wp/wp-admin/ /app/plugins/ /app/themes/ /app/mu-plugins/ /app/cache/ /app/uploads/fusion-styles/ /app/uploads/fusion-scripts/ /app/uploads/sites/*/fusion-styles/ /app/uploads/sites/*/fusion-scripts/ /wp-includes/ /wp-admin/ /wp-content/plugins/ /wp-content/themes/ /wp-content/mu-plugins/ /wp-content/cache/ /wp-content/uploads/fusion-styles/ /wp-content/uploads/fusion-scripts/ /wp-content/uploads/sites/*/fusion-styles/ /wp-content/uploads/sites/*/fusion-scripts/" CADDY_MEDIA_PATHS="/app/uploads/ /wp-content/uploads/" + # WordPress sizing. WP_MEMORY_LIMIT is meaningless above the PHP limit, so this # must be >= whatever the site sets in wp-config/application.php. ENV PHP_MEMORY_LIMIT=512M \ diff --git a/php/8.3/frankenphp/docker-configure b/php/8.3/frankenphp/docker-configure index 4b84a10..f19693d 100644 --- a/php/8.3/frankenphp/docker-configure +++ b/php/8.3/frankenphp/docker-configure @@ -134,6 +134,67 @@ ext_alternation() { done } > "${CADDY_SITE_D}/00-hardening.caddyfile" +# --------------------------------------------------------------------------- +# Caddy cache-control snippet for static assets +# +# Only rendered when a path list is set (the base image sets none; the +# WordPress layer supplies both layouts). Two tiers: +# CADDY_IMMUTABLE_ASSET_PATHS -- prefixes whose files are content-hashed or +# carry ?ver= in their URLs (core, plugins, themes, minifier/compiler +# output). A change always means a new URL, so cache for a year. +# CADDY_MEDIA_PATHS -- media library uploads, which keep their filename when +# replaced in place. A shorter TTL bounds how long a stale copy lives. +# Both are space-separated path prefixes; "*" matches one path segment +# (e.g. /app/uploads/sites/*/fusion-styles/). Extension lists are +# space-separated without leading dots. The `file` matcher restricts the +# header to files that exist on disk, so a 404 is never cached long-term. +# Without these headers Cloudflare falls back to a short edge TTL and every +# PoP revalidates against the origin independently. +# --------------------------------------------------------------------------- + +# Space-separated path prefixes -> regex alternation. Escapes "." and "+", +# turns "*" into a single-segment wildcard. +path_alternation() { + _pattern="" + for _p in $1; do + _escaped=$(printf '%s' "$_p" | sed -e 's|[.+]|\\&|g' -e 's|\*|[^/]+|g') + if [ -z "$_pattern" ]; then + _pattern="$_escaped" + else + _pattern="${_pattern}|${_escaped}" + fi + done + printf '%s' "$_pattern" +} + +if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ] || [ -n "${CADDY_MEDIA_PATHS}" ]; then + { + if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_IMMUTABLE_ASSET_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_IMMUTABLE_ASSET_EXTENSIONS:-css js mjs woff woff2 ttf otf eot svg png jpg jpeg gif webp avif ico}") + echo "@immutable_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @immutable_assets Cache-Control \"public, max-age=${CADDY_IMMUTABLE_ASSET_MAX_AGE:-31536000}, immutable\"" + fi + + if [ -n "${CADDY_MEDIA_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_MEDIA_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_MEDIA_EXTENSIONS:-png jpg jpeg gif webp avif svg ico mp4 webm mp3 pdf woff woff2 ttf otf}") + echo "@media_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @media_assets Cache-Control \"public, max-age=${CADDY_MEDIA_MAX_AGE:-2592000}\"" + fi + } > "${CADDY_SITE_D}/10-cache-headers.caddyfile" +else + # A site that clears both lists must not inherit a stale snippet from a + # previous boot of the same container filesystem. + rm -f "${CADDY_SITE_D}/10-cache-headers.caddyfile" +fi + # --------------------------------------------------------------------------- # msmtp # --------------------------------------------------------------------------- diff --git a/php/8.4/frankenphp/Dockerfile.wordpress b/php/8.4/frankenphp/Dockerfile.wordpress index 956fe32..3026031 100644 --- a/php/8.4/frankenphp/Dockerfile.wordpress +++ b/php/8.4/frankenphp/Dockerfile.wordpress @@ -75,6 +75,15 @@ ENV PHP_DENY_EXTENSIONS="sql sql.gz bak old log" # backup plugins need them. Add them per-site if nothing on that site does. ENV PHP_DISABLE_FUNCTIONS="exec,passthru,shell_exec,system,pcntl_exec,dl" +# Static asset caching (rendered into a Caddy snippet at boot). Covers both +# layouts. Core, plugin and theme assets carry ?ver= in their URLs, and cache +# plugins / the Avada compiler write content-hashed files, so a change is always +# a new URL: cache those for a year. Media library files keep their filename if +# replaced in place, so they get 30 days. Both are per-site overridable; "*" +# matches one path segment (multisite uploads/sites/N/). +ENV CADDY_IMMUTABLE_ASSET_PATHS="/wp/wp-includes/ /wp/wp-admin/ /app/plugins/ /app/themes/ /app/mu-plugins/ /app/cache/ /app/uploads/fusion-styles/ /app/uploads/fusion-scripts/ /app/uploads/sites/*/fusion-styles/ /app/uploads/sites/*/fusion-scripts/ /wp-includes/ /wp-admin/ /wp-content/plugins/ /wp-content/themes/ /wp-content/mu-plugins/ /wp-content/cache/ /wp-content/uploads/fusion-styles/ /wp-content/uploads/fusion-scripts/ /wp-content/uploads/sites/*/fusion-styles/ /wp-content/uploads/sites/*/fusion-scripts/" \ + CADDY_MEDIA_PATHS="/app/uploads/ /wp-content/uploads/" + # WordPress sizing. WP_MEMORY_LIMIT is meaningless above the PHP limit, so this # must be >= whatever the site sets in wp-config/application.php. ENV PHP_MEMORY_LIMIT=512M \ diff --git a/php/8.4/frankenphp/docker-configure b/php/8.4/frankenphp/docker-configure index 4b84a10..f19693d 100644 --- a/php/8.4/frankenphp/docker-configure +++ b/php/8.4/frankenphp/docker-configure @@ -134,6 +134,67 @@ ext_alternation() { done } > "${CADDY_SITE_D}/00-hardening.caddyfile" +# --------------------------------------------------------------------------- +# Caddy cache-control snippet for static assets +# +# Only rendered when a path list is set (the base image sets none; the +# WordPress layer supplies both layouts). Two tiers: +# CADDY_IMMUTABLE_ASSET_PATHS -- prefixes whose files are content-hashed or +# carry ?ver= in their URLs (core, plugins, themes, minifier/compiler +# output). A change always means a new URL, so cache for a year. +# CADDY_MEDIA_PATHS -- media library uploads, which keep their filename when +# replaced in place. A shorter TTL bounds how long a stale copy lives. +# Both are space-separated path prefixes; "*" matches one path segment +# (e.g. /app/uploads/sites/*/fusion-styles/). Extension lists are +# space-separated without leading dots. The `file` matcher restricts the +# header to files that exist on disk, so a 404 is never cached long-term. +# Without these headers Cloudflare falls back to a short edge TTL and every +# PoP revalidates against the origin independently. +# --------------------------------------------------------------------------- + +# Space-separated path prefixes -> regex alternation. Escapes "." and "+", +# turns "*" into a single-segment wildcard. +path_alternation() { + _pattern="" + for _p in $1; do + _escaped=$(printf '%s' "$_p" | sed -e 's|[.+]|\\&|g' -e 's|\*|[^/]+|g') + if [ -z "$_pattern" ]; then + _pattern="$_escaped" + else + _pattern="${_pattern}|${_escaped}" + fi + done + printf '%s' "$_pattern" +} + +if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ] || [ -n "${CADDY_MEDIA_PATHS}" ]; then + { + if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_IMMUTABLE_ASSET_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_IMMUTABLE_ASSET_EXTENSIONS:-css js mjs woff woff2 ttf otf eot svg png jpg jpeg gif webp avif ico}") + echo "@immutable_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @immutable_assets Cache-Control \"public, max-age=${CADDY_IMMUTABLE_ASSET_MAX_AGE:-31536000}, immutable\"" + fi + + if [ -n "${CADDY_MEDIA_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_MEDIA_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_MEDIA_EXTENSIONS:-png jpg jpeg gif webp avif svg ico mp4 webm mp3 pdf woff woff2 ttf otf}") + echo "@media_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @media_assets Cache-Control \"public, max-age=${CADDY_MEDIA_MAX_AGE:-2592000}\"" + fi + } > "${CADDY_SITE_D}/10-cache-headers.caddyfile" +else + # A site that clears both lists must not inherit a stale snippet from a + # previous boot of the same container filesystem. + rm -f "${CADDY_SITE_D}/10-cache-headers.caddyfile" +fi + # --------------------------------------------------------------------------- # msmtp # --------------------------------------------------------------------------- diff --git a/php/8.5/frankenphp/Dockerfile.wordpress b/php/8.5/frankenphp/Dockerfile.wordpress index bbecd1a..8637212 100644 --- a/php/8.5/frankenphp/Dockerfile.wordpress +++ b/php/8.5/frankenphp/Dockerfile.wordpress @@ -75,6 +75,14 @@ ENV PHP_DENY_EXTENSIONS="sql sql.gz bak old log" # backup plugins need them. Add them per-site if nothing on that site does. ENV PHP_DISABLE_FUNCTIONS="exec,passthru,shell_exec,system,pcntl_exec,dl" +# Static asset caching (rendered into a Caddy snippet at boot). Covers both +# layouts. Core, plugin and theme assets carry ?ver= in their URLs, and cache +# plugins / the Avada compiler write content-hashed files, so a change is always +# a new URL: cache those for a year. Media library files keep their filename if +# replaced in place, so they get 30 days. Both are per-site overridable; "*" +# matches one path segment (multisite uploads/sites/N/). +ENV CADDY_IMMUTABLE_ASSET_PATHS="/wp/wp-includes/ /wp/wp-admin/ /app/plugins/ /app/themes/ /app/mu-plugins/ /app/cache/ /app/uploads/fusion-styles/ /app/uploads/fusion-scripts/ /app/uploads/sites/*/fusion-styles/ /app/uploads/sites/*/fusion-scripts/ /wp-includes/ /wp-admin/ /wp-content/plugins/ /wp-content/themes/ /wp-content/mu-plugins/ /wp-content/cache/ /wp-content/uploads/fusion-styles/ /wp-content/uploads/fusion-scripts/ /wp-content/uploads/sites/*/fusion-styles/ /wp-content/uploads/sites/*/fusion-scripts/" CADDY_MEDIA_PATHS="/app/uploads/ /wp-content/uploads/" + # WordPress sizing. WP_MEMORY_LIMIT is meaningless above the PHP limit, so this # must be >= whatever the site sets in wp-config/application.php. ENV PHP_MEMORY_LIMIT=512M \ diff --git a/php/8.5/frankenphp/docker-configure b/php/8.5/frankenphp/docker-configure index 4b84a10..f19693d 100644 --- a/php/8.5/frankenphp/docker-configure +++ b/php/8.5/frankenphp/docker-configure @@ -134,6 +134,67 @@ ext_alternation() { done } > "${CADDY_SITE_D}/00-hardening.caddyfile" +# --------------------------------------------------------------------------- +# Caddy cache-control snippet for static assets +# +# Only rendered when a path list is set (the base image sets none; the +# WordPress layer supplies both layouts). Two tiers: +# CADDY_IMMUTABLE_ASSET_PATHS -- prefixes whose files are content-hashed or +# carry ?ver= in their URLs (core, plugins, themes, minifier/compiler +# output). A change always means a new URL, so cache for a year. +# CADDY_MEDIA_PATHS -- media library uploads, which keep their filename when +# replaced in place. A shorter TTL bounds how long a stale copy lives. +# Both are space-separated path prefixes; "*" matches one path segment +# (e.g. /app/uploads/sites/*/fusion-styles/). Extension lists are +# space-separated without leading dots. The `file` matcher restricts the +# header to files that exist on disk, so a 404 is never cached long-term. +# Without these headers Cloudflare falls back to a short edge TTL and every +# PoP revalidates against the origin independently. +# --------------------------------------------------------------------------- + +# Space-separated path prefixes -> regex alternation. Escapes "." and "+", +# turns "*" into a single-segment wildcard. +path_alternation() { + _pattern="" + for _p in $1; do + _escaped=$(printf '%s' "$_p" | sed -e 's|[.+]|\\&|g' -e 's|\*|[^/]+|g') + if [ -z "$_pattern" ]; then + _pattern="$_escaped" + else + _pattern="${_pattern}|${_escaped}" + fi + done + printf '%s' "$_pattern" +} + +if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ] || [ -n "${CADDY_MEDIA_PATHS}" ]; then + { + if [ -n "${CADDY_IMMUTABLE_ASSET_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_IMMUTABLE_ASSET_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_IMMUTABLE_ASSET_EXTENSIONS:-css js mjs woff woff2 ttf otf eot svg png jpg jpeg gif webp avif ico}") + echo "@immutable_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @immutable_assets Cache-Control \"public, max-age=${CADDY_IMMUTABLE_ASSET_MAX_AGE:-31536000}, immutable\"" + fi + + if [ -n "${CADDY_MEDIA_PATHS}" ]; then + path_pattern=$(path_alternation "${CADDY_MEDIA_PATHS}") + ext_pattern=$(ext_alternation "${CADDY_MEDIA_EXTENSIONS:-png jpg jpeg gif webp avif svg ico mp4 webm mp3 pdf woff woff2 ttf otf}") + echo "@media_assets {" + echo " path_regexp ^(${path_pattern}).*\\.(${ext_pattern})\$" + echo " file" + echo "}" + echo "header @media_assets Cache-Control \"public, max-age=${CADDY_MEDIA_MAX_AGE:-2592000}\"" + fi + } > "${CADDY_SITE_D}/10-cache-headers.caddyfile" +else + # A site that clears both lists must not inherit a stale snippet from a + # previous boot of the same container filesystem. + rm -f "${CADDY_SITE_D}/10-cache-headers.caddyfile" +fi + # --------------------------------------------------------------------------- # msmtp # ---------------------------------------------------------------------------