# Production. public/ is baked into the image (Dockerfile, target caddy);
# storage/app is the shared `storage` volume, read-only.
# No page cache here: nginx's FastCGI cache is dropped on purpose, the
# static page cache comes later (P2).
{
	import global.caddy
}

import common.caddy

:80 {
	import site

	route {
		import deny_dotfiles
		import stoic

		# Content-hashed or versioned files: cache forever.
		@immutable path /build/* /static/* /packages/*
		handle @immutable {
			header Cache-Control "public, max-age=31536000, immutable"
			file_server
		}

		# User media, straight from the storage volume (no symlink needed).
		handle_path /storage/* {
			root * /var/www/html/storage/app/public
			header Cache-Control "public, max-age=31536000, immutable"
			file_server
		}

		# Generated by the app into storage/app.
		handle /sitemap.xml {
			root * /var/www/html/storage/app
			header Cache-Control "public, max-age=3600"
			header Content-Type "application/xml; charset=utf-8"
			file_server
		}

		import laravel
	}

	import static_404
}
