Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send_file should set conditional=True and no-cache by default #1882

Closed
davidism opened this issue Jul 13, 2020 · 0 comments · Fixed by #1886
Closed

send_file should set conditional=True and no-cache by default #1882

davidism opened this issue Jul 13, 2020 · 0 comments · Fixed by #1886
Assignees
Milestone

Comments

@davidism
Copy link
Member

davidism commented Jul 13, 2020

Currently, send_file sets cache_timeout to 12 hours, and disables conditional by default. We see a regular stream of questions from developers who are confused why their CSS changes aren't reflected in development, or even when deploying a new version. 12 hours is really long, even CDNs default to around 1-4 hours.

Instead, we should set conditional=True by default, set cache_control.no_cache instead of public, and not set max_age or expires. This will tell the client to cache the response, but to make conditional requests to decide whether to use the cache.

This will solve the issue developers are having with stale resources. It adds a bit of overhead since it requires a request cycle to calculate if the conditions are still met, but I think this should be negligible for most applications. If an application is at the point where that overhead matters, they should be using a CDN, at which point they would be tuning cache-control anyway.

Related to #1850

cc @jab

@davidism davidism added this to the 2.0.0 milestone Jul 13, 2020
@davidism davidism self-assigned this Jul 13, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant