-
Notifications
You must be signed in to change notification settings - Fork 25k
feat(image): [android] adding force-cache cache control option
#47426
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
feat(image): [android] adding force-cache cache control option
#47426
Conversation
...ve/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/ReactOkHttpNetworkFetcher.kt
Show resolved
Hide resolved
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Abbondanzo
left a comment
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.
The cacheControlBuilder has noStore set, so none of the responses are getting cached.
- Could you modify the builder to set
noStoreon the default andreloadbranches? - Could you update the
only-if-cachedbranch to use the same max-age logic?
…or only-if-cached
|
@Abbondanzo thanks a lot again for taking the time to check these PRs! I've addressed all the feedback in dca3d3a |
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@Abbondanzo merged this pull request in a0be88f. |
|
This pull request was successfully merged by @mateoguzmana in a0be88f When will my fix make it into a release? | How to file a pick request? |
…ts (#47953) Summary: This is a follow up for the new cache control options for the Android Image component introduced in #47182, #47348 & #47426. And to make sure the cache control header works as expected and avoid missing the issue fixed in #47922, this PR introduces test cases to make sure this is getting applied as expected in the `ReactOkHttpNetworkFetcher`. ## Changelog: [INTERNAL] [ADDED] - `ReactOkHttpNetworkFetcher` cache control tests Pull Request resolved: #47953 Test Plan: ```bash yarn test-android ``` Reviewed By: rshest Differential Revision: D66498305 Pulled By: javache fbshipit-source-id: 7a9a0cc596e49964943e59189614743ca8a472a1
Summary:
This PR follows up on #47182 and #47348 by adding
force-cache, the final missing option to align caching controls with the existing behavior on iOS.Local caching behavior remains unchanged: if a cached image is available locally, it will be returned; otherwise, a network request will be made.
When an image request is sent over the network, the
force-cacheoption sent from the sent fJS side will now use theokhttp3.CacheControl.FORCE_CACHEdirective.Changelog:
[ANDROID] [ADDED] - Image
force-cachecaching control optionTest Plan:
New example added to the RNTester under the cache policy examples. Then inspecting that the cache control is set correctly before sending it in the
okhttp3.Requestbuilder.This case was a bit more tricky to test in terms of e2e as it would involve some caching in the server as well, I'm open to suggestions to make this more complete.