-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
clean up cache control attributes #2980
Comments
Sourcegraph https://sourcegraph.com/search?q=context:global+lang:Python+%27request.cache_control.max_stale+%3D%3D+%22*%22%27&patternType=keyword&sm=0 finds no uses of I'm thinking we simplify the type of this by breaking it into two properties: Searching around a bit, .Net also uses two properties: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.headers.cachecontrolheadervalue.maxstalelimit?view=net-8.0 A thorough check would be: if max_stale_any:
if max_stale is None:
present no value
else:
present with value A basic check would be: if max_stale is not None:
present with value Currently the check requires if max_stale is not None:
if isinstance(max_stale, str):
present no value
else:
present with value if max_stale is not None and not isinstance(max_stale, str):
present with value |
See #2981 for in depth explanation for the changes made after investigating the code and spec. |
The implementation for cache control attributes is pretty messy. Some of the default values are incorrect, such as setting a string
"*"
for a value that should be boolean, or using-1
instead ofNone
for a missing attribute. It is hard to type correctly, and hard to reason about when making changes.Get rid of the property factory and implement each attribute directly instead, cleaning up the types and defaults to match the actual HTTP spec. Unfortunately, there's no way to deprecate the previous incorrect values, but from looking over it it seems like they would be unlikely to be relied upon, and it's easy to fix code that does.
The text was updated successfully, but these errors were encountered: