Skip to content

Fix static file caching for Development hot reload and CDN no-transform #11 - #12

Closed
yasmoradi wants to merge 1 commit into
developfrom
fix/11-static-file-caching-dev-cdn
Closed

Fix static file caching for Development hot reload and CDN no-transform #11#12
yasmoradi wants to merge 1 commit into
developfrom
fix/11-static-file-caching-dev-cdn

Conversation

@yasmoradi

Copy link
Copy Markdown
Owner

Summary

Reworks static-file caching into a middleware using Response.OnStarting, adds no-cache in Development, and keeps NoTransform for versioned production assets.

  • Development: sends Cache-Control: no-cache, which fixes SCSS changes sometimes not applying under Hot Reload / dotnet watch.
  • Production: keeps Public + NoTransform + max-age for versioned (?v=) assets. NoTransform prevents CDNs from re-compressing the already highly-compressed Blazor publish output, reducing the size served behind the CDN.

Changes

  • Program.Middlewares: replace UseStaticFiles(OnPrepareResponse = ...) with a middleware that sets Cache-Control on Response.OnStarting (no-cache in Development; Public + NoTransform + max-age for versioned assets in production), followed by UseStaticFiles().
  • Add wwwroot/_framework/.gitkeep to the Windows client so the folder is tracked (also helps dotnet watch).

Related Issue

This closes #11

@yasmoradi yasmoradi added bug Something isn't working area / templates Relates to the bit Boilerplate project template labels Jul 22, 2026
@yasmoradi

Copy link
Copy Markdown
Owner Author

Superseded: opened on upstream as bitfoundation#12764. This fork PR was created by mistake.

@yasmoradi yasmoradi closed this Jul 22, 2026
@yasmoradi
yasmoradi deleted the fix/11-static-file-caching-dev-cdn branch July 22, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area / templates Relates to the bit Boilerplate project template bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static file responses aren't marked no-cache in Development and are re-compressed by CDNs in production

1 participant