React-native-fast-image: FastImage.cache.web does not work on Android

Created on 12 Sep 2018  路  11Comments  路  Source: DylanVann/react-native-fast-image

FastImage.cache.web - Use headers and follow normal caching procedures.

@DylanVann
The image view does not render when use the property cache: 'web'

<FastImage
    source={{
    uri: source.uri,
    cache: 'web'
}}/>                                                         

All 11 comments

It renders for me, but doesn't seem to cache.

Hi @DylanVann, I can see the images flickering, so it seems the component doesn't re-use what was downloaded before. Do you have any means to reproduce this?

I tried setting skipMemoryCache = true to false in RequestOptions, but looks like I get the default behaviour instead. :(

@edo1493 experiencing the same problem. Cache strategy web doesn't seem to work on Android. Did you find a workaround for this?

Same problem here, any news?

@DylanVann Do you know any workaround?

@edo1493 Any idea why on Android it is not caching the images when set to web mode?

I dug into this as it was a blocker for me using it.
Seems like the OkHttpClient didn't have a cache configured.

I fixed this locally with a patch. (using patch-package)
In FastImageOkHttpProgressGlideModule.java
I added a cache

         OkHttpClient client = OkHttpClientProvider
                 .getOkHttpClient()
                 .newBuilder()
+                .cache(new Cache(
+                    new File(context.getCacheDir(), "image-cache"),
+                    100 * 1024 * 1024))
                 .addInterceptor(createInterceptor(progressListener))
                 .build();

Replace "100 * 1024 * 1024" with whatever cache size you want.

Disclaimer. I'm not sure if this affects the other caching methods, but I always want to use web in my app, so I wasn't concerned.

Same problem here, any solution?

Hi, seems like this issue is not getting any attention. Are there other image solutions that have proper caching?

Any solution or workaround ? I am stuck on this.

Any solution or workaround ? I am stuck on this.

I did it using this solution and made a patch and it fixed it.

https://github.com/DylanVann/react-native-fast-image/issues/280#issuecomment-603530248

Was this page helpful?
0 / 5 - 0 ratings