Home > database >  Cache is not getting cleared with FFimage
Cache is not getting cleared with FFimage

Time:11-18

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)

CodePudding user response:

Try to clear it on property setter

private string _imageSource{ get; set; }
public string image1Source
{
get{
     return _imageSource;
   };
set{
     _imageSource= value;
     await CachedImage.InvalidateCache(_imageSource, CacheType.All, true);
   };
}

CodePudding user response:

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.

  • Related