From 44d4482513805698400e398ee13d150bb24070a1 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Thu, 13 Apr 2023 11:44:23 +0100 Subject: [PATCH] Specify caching policy for XML/MSI downloads Signed-off-by: Danilo Del Busso --- XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs | 2 ++ XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs b/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs index ace662910..3724bb570 100644 --- a/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs +++ b/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs @@ -33,6 +33,7 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Net; +using System.Net.Cache; using System.Net.NetworkInformation; using System.Security.Cryptography.X509Certificates; using System.Threading; @@ -84,6 +85,7 @@ namespace XenAdmin.Actions.Updates _client = new WebClient(); _client.DownloadProgressChanged += client_DownloadProgressChanged; _client.DownloadFileCompleted += client_DownloadFileCompleted; + _client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); // register event handler to detect changes in network connectivity NetworkChange.NetworkAvailabilityChanged += NetworkAvailabilityChanged; diff --git a/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs b/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs index 46c14ddcf..9479170e1 100644 --- a/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs +++ b/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs @@ -36,6 +36,7 @@ using System.Xml; using XenAdmin.Core; using System.Diagnostics; using System.Net; +using System.Net.Cache; namespace XenAdmin.Actions @@ -356,6 +357,8 @@ namespace XenAdmin.Actions using (var webClient = new WebClient()) { + webClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); + webClient.Proxy = proxy; webClient.Headers.Add("User-Agent", _userAgent); using (var stream = new MemoryStream(webClient.DownloadData(uriBuilder.Uri)))