C#: WinForms – Manage Cache state with Webclient CachePolicy
When using Webclient to retrieve some file from the web you can face problem with caching your files.
For example: You have a xml file with version number inside. After downloading first time by Webclient class, you changed content of the xml file and start process again. Unfortunately you will receive old content downloaded earlier instead newest content of the file.
That happens because of Microsoft Internet Explorer (as far as I know) Cache settings used by Webclient class.
So to disallow for caching your requests you have to change Weblicent CachePolicy property. You can do it as shown below:
string xmlUrl = "http://myserver.com/xmlfile.xml"; WebClient client = new WebClient(); // prevent file caching by windows client.CachePolicy = new System.Net.Cache.RequestCachePolicy( System.Net.Cache.RequestCacheLevel.NoCacheNoStore ); // read content of file Stream rssStream = client.OpenRead(xmlUrl);

(299)


Very nice tip indeed!
I do not know how many people did find it – http://silverlight.net/forums/t/14453.aspx
regards,
Digvijay