Add cache control to Files API static assets

Brand assets served at /api/files/v1/static had no cache headers.
Introduce brand.Assets to own the embedded filesystem, content-hash
ETags, and HTTP serving. Responses now carry Cache-Control and ETag
so clients can cache and revalidate; stable email URLs stay
revalidatable (max-age=3600, no immutable).

Replace hardcoded Default*Path constants with StaticPathPrefix,
logical filename constants, and StaticPath(). NewAssets validates
required assets at startup so a rename fails fast instead of 404ing
in sent emails. The files handler keeps routing and 404 rendering;
ServeAssets sets cache headers and serves the file.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
Ludovic Vielle
2026-06-12 12:14:40 +02:00
parent c33540637d
commit dbfd191bc5
8 changed files with 208 additions and 68 deletions

View File

@@ -66,10 +66,10 @@ func DefaultPresenterConfig(baseURL string) PresenterConfig {
return PresenterConfig{
APIBaseURL: baseURL, // always API base URL
BaseURL: baseURL, // can change to custom domain when needed
PoweredByLogoPath: brand.DefaultPoweredByLogoPath,
PoweredByLogoPath: brand.StaticPath(brand.PoweredByLogo),
SenderCompanyName: "Probo",
SenderCompanyWebsiteURL: "https://www.probo.com",
SenderCompanyLogoPath: brand.DefaultSenderCompanyLogoPath,
SenderCompanyLogoPath: brand.StaticPath(brand.SenderCompanyLogo),
SenderCompanyHeadquarterAddress: "Probo Inc, 490 Post St, STE 640, San Francisco, CA, 94102, US",
}
}