Search code examples
xamarinxamarin.formsxamarin.androidffimageloading

Cache is not getting cleared with FFimage


I am trying to test FFImage Cached Image. Even after invalidating the cache, the image is not getting refreshed.

The old image is still coming.

<StackLayout Orientation="Horizontal">
    <StackLayout>
        <Label Text="1.jpg 15 min" FontSize="Title"/>
        <ffimage:CachedImage HeightRequest="150" WidthRequest="150" Source="{Binding image1Source}" 
                             CacheDuration="{Binding Duration}"/>
    </StackLayout>
    <StackLayout>
        <Label Text="2.jpg 15 min" FontSize="Title"/>
        <ffimage:CachedImage HeightRequest="150" WidthRequest="150" Source="{Binding image2Source}" 
                             CacheDuration="{Binding Duration}"/>
    </StackLayout>
</StackLayout>

Calling below to invalidate Cache:

FFImageLoading.ImageService.Instance.InvalidateDiskCacheAsync()
FFImageLoading.ImageService.Instance.InvalidateMemoryCache();
FFImageLoading.ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All)

Solution

  • The issue was due to caching on the image url as well. the mobile cache was being clear but the server image was cached as well and hence we were getting the same image again which gave the impression of cache not being cleared.