c# HttpClient禁止缓存

using (var client = new HttpClient())
            {

               //方法1:

                CacheControlHeaderValue cacheControl = new CacheControlHeaderValue();
                cacheControl.NoCache = true;
                cacheControl.NoStore = true;
                client.DefaultRequestHeaders.CacheControl = cacheControl;

               //方法2:

                //client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
                try
                {
                    client.GetStringAsync(url);
                    return true;
                }
                catch
                {
                    return false;
                }
            }

原文地址:https://www.cnblogs.com/94cool/p/5949082.html