Skip to content

Commit 5c211f2

Browse files
matpaulfacebook-github-bot
authored andcommitted
fix: image cache did not take into account request cache policy (facebook#34556)
Summary: Image Component cache = 'reload' prop not worked correct because inner Image cache did not take into account request cache (cache property convert in RCTConvert into request.cachePolicy). Fixes facebook#9195 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [Fixed] - Image Component will not update correctly when passing in new url Pull Request resolved: facebook#34556 Test Plan: Reproduce code: https://snack.expo.dev/rundbom/image-should-update Reviewed By: cipolleschi Differential Revision: D39206324 Pulled By: jacdebug fbshipit-source-id: 2293382279e92f3b2bfcd36b54af47d1813c5cdf
1 parent 1dd74db commit 5c211f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Libraries/Image/RCTImageLoader.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req
501501
BOOL cacheResult = [loadHandler respondsToSelector:@selector(shouldCacheLoadedImages)] ?
502502
[loadHandler shouldCacheLoadedImages] : YES;
503503

504+
if (request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) {
505+
cacheResult = NO;
506+
}
507+
504508
if (cacheResult && partialLoadHandler) {
505509
UIImage *image = [[self imageCache] imageForUrl:request.URL.absoluteString
506510
size:size

0 commit comments

Comments
 (0)