' The following method demonstrates overriding the
' caching policy for a request.
Public Shared Function GetResponseNoCache(ByVal uri As Uri) As WebResponse
' Set a default policy level for the "http:" and "https" schemes.
Dim policy As New HttpRequestCachePolicy(HttpRequestCacheLevel.Default)
HttpWebRequest.DefaultCachePolicy = policy
' Create the request.
Dim request As WebRequest = WebRequest.Create(uri)
' Define a cache policy for this request only.
Dim noCachePolicy As New HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore)
request.CachePolicy = noCachePolicy
Dim response As WebResponse = request.GetResponse()
Console.WriteLine("IsFromCache? {0}", response.IsFromCache)
Return response
End Function