-
Notifications
You must be signed in to change notification settings - Fork 56
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
enhancement: Set URLRequest cache policy on GET requests #476
Conversation
✅ Deploy Preview for eclectic-pie-88a2ba canceled.
|
✅ Deploy Preview for apollo-ios-docc canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, think the mappings of the cache policies makes sense
The only question I have is whether the following should ignore remote caches or not?
|
Yea I think thats a reasonable assumption that it should ignore anything cached on the iOS client side which is what Apollo iOS would be doing, but could still use remote cached responses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Calvin!
6620447d enhancement: Set URLRequest cache policy on GET requests (#476) git-subtree-dir: apollo-ios git-subtree-split: 6620447d66a270c5605529f0a51ccfdd5d9769c9
…y on GET requests git-subtree-dir: apollo-ios git-subtree-mainline: c9f0bfd git-subtree-split: 6620447d66a270c5605529f0a51ccfdd5d9769c9
Closes apollographql/apollo-ios#3432.
There is currently no way for a user to opt-out of the URLRequest default caching behaviour. This PR simply sets a comparable cache policy on
URLRequest
forGET
requests.returnCacheDataElseFetch
==returnCacheDataElseLoad
: Direct comparisonfetchIgnoringCacheData
==reloadIgnoringLocalCacheData
: The Apollo iOS version of this cache policy means that only the request will ignore cached data but the response will still be cached. It seems correct to ignore any iOS cached responses but still use any remote (CDN) cached responses.fetchIgnoringCacheCompletely
==reloadIgnoringLocalAndRemoteCacheData
: The Apollo iOS version of this cache policy will ignore cached data for the request but it will also not cache any response data. The equivalentURLRequest
policy here is to ignore all local (iOS) and remote (CDN) cached data and always go to the server for a response.returnCacheDataDontFetch
==returnCacheDataDontLoad
: Direct comparisonreturnCacheDataAndFetch
==reloadRevalidatingCacheData
: The Apollo iOS request chain will handle the return-cache-data portion of this policy but we extend that to any iOS cached responses, for and-fetch, by making iOS ensure any cached responses are still valid, otherwise fetch from the server.