Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Image Source always picking image from cache.

amitranjanamitranjan Member ✭✭

Hi , I am using Image control in Xamarin forms android app. Used at two places one on hamburger slider and another on a content page. i am resolving image from webapi and using the code below:
private void OnPresentedChanged(object sender, EventArgs e)
{

            ImgProfile.Source = new UriImageSource()
            {
                Uri = new Uri(Constants.ProfilePicUrl),
                CachingEnabled = true,
                CacheValidity = new TimeSpan(5,0,0,0)
            };
        }

I tried aove code with both the conditions CachingEnabled = true/false . Here is what I observed:

  1. CachingEnabled = False : Each time the image control flickers and reloads the image. I can see a time gap of second or two between image reload from web url. Similary in the slider menu.
  2. CachingEnabled = true: My image control keeps on displaying the cached version even if the url has newer/different image, as its profile page and user can change his/her profile image N times a day.

So #1 solves my problem but the flickering part is annoying. Also please note , profile image is taken and uploaded from camera so there no way of uploading a customized image with lesser size to eliminate the delay..

I hope , my problem is clear to you guys.

Answers

  • stXamDevstXamDev Member ✭✭✭

    use FFImageLoading , it solved all your problems

Sign In or Register to comment.