-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[iOS] Enhance image freshness check before stored into cache #23226
Conversation
@@ -31,8 +31,7 @@ typedef dispatch_block_t RCTImageLoaderCancellationBlock; | |||
size:(CGSize)size | |||
scale:(CGFloat)scale | |||
resizeMode:(RCTResizeMode)resizeMode | |||
responseDate:(NSString *)responseDate | |||
cacheControl:(NSString *)cacheControl; |
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.
Only pass responseDate
or cacheControl
may not sufficient, we can just pass response
that we can get any response header we want.
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 for adding this functionality. Passing the response directly seems like the right choice as it simplifies the callsites.
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@zhongwuzw merged commit e98d5a2 into |
Just landed this one again in fb8ba3f |
Summary: Currently, before we store the image to cache, we only respect `Cache-Control`, actually, we also may need to check `Expires`、`Last-Modified`, refer to [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#Freshness), and [okhttp](https://github.com/square/okhttp/blob/568a91c44a118b2c2ba62d310a331582c567b24a/okhttp/src/main/java/okhttp3/internal/cache/CacheStrategy.java#L268) respect the `MDN`, so in iOS, we can also respect this. [iOS] [Fixed] - Respect `MDN` cache strategy before cache the image. After `PR`, if image's response do not contains `Cache-Control`, it would also checks `Expires`、`Last-Modified` refers to [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#Freshness). Pull Request resolved: facebook#23226 Differential Revision: D13895627 Pulled By: cpojer fbshipit-source-id: aa377511c31badd752d7887ed6cbcdf6be4b80b3
Summary
Currently, before we store the image to cache, we only respect
Cache-Control
, actually, we also may need to checkExpires
、Last-Modified
, refer to MDN docs, and okhttp respect theMDN
, so in iOS, we can also respect this.Changelog
[iOS] [Fixed] - Respect
MDN
cache strategy before cache the image.Test Plan
After
PR
, if image's response do not containsCache-Control
, it would also checksExpires
、Last-Modified
refers to MDN docs.