Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does BitmapImage RequestCachePolicy get ignored?

I'm finding that setting the RequestCachePolicy property on BitmapImage has no effect on how the bitmap is downloaded when an Image's Source is set to this instance of BitmapImage.

For example, if I set the RequestCachePolicy to CacheOnly, I would expect no internet traffic to occur whatsoever - the specified image should only be retrieved from the cache. But instead, I see a request being made to the server to download an image:

source = new BitmapImage(bmi.UriSource, 
  new RequestCachePolicy(RequestCacheLevel.CacheOnly));
// An image gets downloaded!

If I set the static DefaultCachePolicy property on HttpWebRequest, then my application behaviour changes in a way I would expect. ie when it's set to CacheOnly, no network traffic occurs.

Why is the RequestCachePolicy property on BitmapImage not having the effect I expect?

like image 999
mackenir Avatar asked Nov 25 '22 15:11

mackenir


1 Answers

According to the MSDN site: http://msdn.microsoft.com/en-us/library/system.net.cache.requestcachepolicy%28v=vs.110%29.aspx

"Caching for Web services is not supported."

like image 67
Andras Sebo Avatar answered Nov 28 '22 05:11

Andras Sebo