New configuration respectMaxAgeZero #503
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a server sends "Cache-Control: max-age=0" this might be a misconfiguration on the server; in this case we should ignore it (the behaviour up to now).
It might also mean, that the content potentially already expired; for this case this commit provides a new configuration parameter to respect this response.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
New configuration parameter so that
Cache-Control: max-age=0
can be treated the same asCache-Control: no-cache
Currently, if the server responds with
Cache-Control: max-age=0
, the library ignores this and sets the max-age to one week.🆕 What is the new behavior (if this is a feature change)?
See above. The default beahaviour is left as-is.
💥 Does this PR introduce a breaking change?
No
🐛 Recommendations for testing
📝 Links to relevant issues/docs
I've seen the discussion in #283
In my app I have this issue: I'm contacting an API (which I cannot control or change) and this API delivers "some kind of" real time data (results for sport games). The server delivers json files; the response contains an etag header and the header
Cache-Control: max-age=0
. So I periodically poll this endpoint and if the etag is still valid I go with the cached file.But the current behaviour of the lib gives me the cached file regardless if the json changed or not. By setting the Config parameter which is introduced here, I can properly work with the API.
I added a new FAQ to the README.md.
🤔 Checklist before submitting
flutter format .
anddart format .
reformatted the whole project. So ... I hope the code formatting is fine.