# neopig SERP Caddyfile
#
# Option 1: Simple reverse proxy with cache headers (let browser/CDN cache)
# Option 2: Use caddy-cache plugin for server-side caching
#
# Run: caddy run --config Caddyfile

:8080 {
    log {
        output stdout
        format console
    }

    # Media files - immutable, cache forever
    @media path /media/*
    handle @media {
        header Cache-Control "public, max-age=31536000, immutable"
        header X-Cache-Status "HIT"
        reverse_proxy localhost:8000
    }

    # API - no cache
    @api path /api/*
    handle @api {
        header Cache-Control "no-cache, no-store"
        reverse_proxy localhost:8000
    }

    # Everything else (UI)
    handle {
        header Cache-Control "no-cache"
        reverse_proxy localhost:8000
    }
}

# Alternative: Direct file serving from vault (faster, bypasses Python)
# Uncomment and adjust paths if you want Caddy to serve files directly:
#
# :8080 {
#     handle /media/* {
#         uri strip_prefix /media
#
#         # Rewrite hash to vault path: abc123... -> ab/abc123...
#         rewrite * /vault/{http.request.uri.path.0}{http.request.uri.path.1}/{http.request.uri.path}
#
#         header Cache-Control "public, max-age=31536000, immutable"
#         file_server {
#             root /path/to/neopig
#         }
#     }
# }
