-
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
feat(image): [android] adding only-if-cached
cache control option
#47348
feat(image): [android] adding only-if-cached
cache control option
#47348
Conversation
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.
A few nits that let Fresco make more of the decisions here
...ges/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt
Outdated
Show resolved
Hide resolved
...ges/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt
Outdated
Show resolved
Hide resolved
…ext to disk check
…droid-option-adjustments Feat/image only if cached android option adjustments
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.
Left a comment in our chain about request levels, that should be the simpler approach
@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 dc9db01. |
This pull request was successfully merged by @mateoguzmana in dc9db01 When will my fix make it into a release? | How to file a pick request? |
) 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-cache` option sent from the sent fJS side will now use the `okhttp3.CacheControl.FORCE_CACHE` directive. ## Changelog: [ANDROID] [ADDED] - Image `force-cache` caching control option Pull Request resolved: #47426 Test 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.Request` builder. ```kt FLog.w("ReactNative", "fetching uri: %s, with cacheControl: %s", uri, cacheControlBuilder.build().toString()) // fetching uri: https:...png?cacheBust=force-cache, with cacheControl: no-store, max-stale=2147483647, only-if-cached ``` 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. Reviewed By: javache Differential Revision: D65490360 Pulled By: Abbondanzo fbshipit-source-id: f807a9793f85caea39c59a370d057b9a1d450a78
…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:
Following up from #47182, as basic caching control is already in place in Android, it can be extended to include the
only-if-cached
option.We check whether the image is in the cache. If it is, we proceed to load it. Otherwise, we do nothing.
Changelog:
[ANDROID] [ADDED] - Image
only-if-cached
cache control optionTest Plan:
In the
rn-tester
, I added a third example for Android where the third image will never be loaded as the cache policy is set toonly-if-cached
and the image has not been loaded before.Video demonstrating how the `only-if-cached` options behaves
Screen.Recording.2024-10-31.at.23.57.04.mov
Error from image not found in cache example