You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Currently,
send_file
setscache_timeout
to 12 hours, and disablesconditional
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, setcache_control.no_cache
instead ofpublic
, and not setmax_age
orexpires
. 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
The text was updated successfully, but these errors were encountered: