Skip to content

Optional Cache-Control header support to Staticfile responses#3248

Open
diskeu wants to merge 2 commits into
Kludex:mainfrom
diskeu:add/static_file-cache-control
Open

Optional Cache-Control header support to Staticfile responses#3248
diskeu wants to merge 2 commits into
Kludex:mainfrom
diskeu:add/static_file-cache-control

Conversation

@diskeu

@diskeu diskeu commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

This adds an optional cache_control parameter to StaticFiles, allowing developers to set a default
Cache-Control header for all static file responses.

This does not change the default behavior when the parameter is not provided.

Why this makes sense

Providing a simple way to configure a default Cache-Control header for static files simplifies common
deployment scenarios.

Many small services rely on a basic cache policy for static assets. This change allows that behavior
to be configured directly without requiring additional middleware or custom wrappers.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@diskeu diskeu force-pushed the add/static_file-cache-control branch from a111d83 to b5780e4 Compare April 22, 2026 17:26
This adds an optional `cache_control` parameter to `Staticfiles` and
allows developers to set a default `Cache-Control` for all served static files.

No changes to the default behavior if `cache_control` is not set.
@diskeu diskeu force-pushed the add/static_file-cache-control branch from b5780e4 to 0f56eb6 Compare April 22, 2026 17:37
@diskeu diskeu force-pushed the add/static_file-cache-control branch from 0f56eb6 to c35c871 Compare April 22, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant