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
Currently,
send_filesetscache_timeoutto 12 hours, and disablesconditionalby 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=Trueby default, setcache_control.no_cacheinstead ofpublic, and not setmax_ageorexpires. 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-controlanyway.Related to #1850
cc @jab