From 5c211f2bce6665468628bc0aa3a8174a474450af Mon Sep 17 00:00:00 2001 From: Pavel Matyukov Date: Mon, 5 Sep 2022 05:21:41 -0700 Subject: [PATCH] fix: image cache did not take into account request cache policy (#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 https://github.com/facebook/react-native/issues/9195 ## Changelog [IOS] [Fixed] - Image Component will not update correctly when passing in new url Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- Libraries/Image/RCTImageLoader.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/Image/RCTImageLoader.mm b/Libraries/Image/RCTImageLoader.mm index 85a1fbae64c4e1..bf64f9c852a254 100644 --- a/Libraries/Image/RCTImageLoader.mm +++ b/Libraries/Image/RCTImageLoader.mm @@ -501,6 +501,10 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req BOOL cacheResult = [loadHandler respondsToSelector:@selector(shouldCacheLoadedImages)] ? [loadHandler shouldCacheLoadedImages] : YES; + if (request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) { + cacheResult = NO; + } + if (cacheResult && partialLoadHandler) { UIImage *image = [[self imageCache] imageForUrl:request.URL.absoluteString size:size