-
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): enabling basic cache control for android #47182
Closed
mateoguzmana
wants to merge
6
commits into
facebook:main
from
mateoguzmana:feat/image-cache-control-android
Closed
feat(image): enabling basic cache control for android #47182
mateoguzmana
wants to merge
6
commits into
facebook:main
from
mateoguzmana:feat/image-cache-control-android
+109
−5
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Oct 23, 2024
Error ReferenceError
Dangerfile
|
facebook-github-bot
added
the
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
label
Oct 23, 2024
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
facebook-github-bot
pushed a commit
that referenced
this pull request
Oct 25, 2024
Summary: Danger seems to have a bug where it's not transpiling the import of rnx-kit/rn-changelog-generator. This mitigates the issue to get our project back on track. This can be replicated locally by: ```bash DEBUG="*" DANGER_GITHUB_API_TOKEN=$GITHUB_TOKEN yarn danger pr #47182 ``` You can see it running correctly here when switching to the branch with the fix. **I'm a little concerned that this is still failing on the PR**. Thoughts? {F1946190275} Changelog: [internal] Pull Request resolved: #47192 Reviewed By: cortinico Differential Revision: D64924466 Pulled By: blakef fbshipit-source-id: 68df0521620809effe3a78ce842e043382ad64a6
This pull request was successfully merged by @mateoguzmana in e5dd7d6 When will my fix make it into a release? | How to file a pick request? |
@Abbondanzo merged this pull request in e5dd7d6. |
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 4, 2024
…47348) 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 option Pull Request resolved: #47348 Test 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 to `only-if-cached` and the image has not been loaded before. <details> <summary>Video demonstrating how the `only-if-cached` options behaves</summary> https://github.com/user-attachments/assets/45669e81-5414-4103-8931-138bffa81447 </details> <details> <summary>Error from image not found in cache example</summary> <img width="807" alt="image" src="https://github.com/user-attachments/assets/6b79d811-1809-437c-b2fe-c86d3da7c58d"> </details> Reviewed By: rshest Differential Revision: D65384639 Pulled By: Abbondanzo fbshipit-source-id: f4a72694f45eb3d7097c350f4a4008a0abf0a1ab
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 12, 2024
) 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
facebook-github-bot
pushed a commit
that referenced
this pull request
Dec 9, 2024
…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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Merged
This PR has been merged.
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
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.
Summary:
Fixes #12606
Previously,
Image
cache control options were not functional on Android, even though they were being passed to the native component via thesource
prop. This PR addresses that by implementing logic to manage cache behaviour on Android.When the
reload
option is explicitly set, the image is now evicted from both memory and disk caches before a new request is made. This ensures the image is always fetched from the source, aligning the caching behaviour between Android and iOS for thedefault
andreload
options.Changelog:
[ANDROID][ADDED] - Enabling basic
Image
cache control for AndroidTest Plan:
Added a new example to the
rn-tester
, where we can notice that the image on the right is reloaded if rendered or re-rendered as the cache policy is set toreload
. The image on the left has the cache policy set todefault
and won't be re-rendered as the image is already in the cache. See the video below:Screen.Recording.2024-10-23.at.23.31.02.mov
Also tested on both old and new architecture.