chore: change caching behaviour for pluginmasters

This commit is contained in:
goaaats 2022-04-17 15:10:29 +02:00
parent 9a5e3bcf22
commit 417862765a
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Utility;
using Newtonsoft.Json;
namespace Dalamud.Plugin.Internal
@ -19,6 +20,17 @@ namespace Dalamud.Plugin.Internal
private static readonly ModuleLog Log = new("PLUGINR");
private static HttpClient HttpClient = new()
{
DefaultRequestHeaders =
{
CacheControl = new CacheControlHeaderValue
{
NoCache = true,
},
},
};
/// <summary>
/// Initializes a new instance of the <see cref="PluginRepository"/> class.
/// </summary>
@ -74,8 +86,7 @@ namespace Dalamud.Plugin.Internal
{
Log.Information($"Fetching repo: {this.PluginMasterUrl}");
// ?ticks causes a cache invalidation. Get a fresh repo every time.
using var response = await Util.HttpClient.GetAsync(this.PluginMasterUrl + "?" + DateTime.Now.Ticks);
using var response = await HttpClient.GetAsync(this.PluginMasterUrl);
response.EnsureSuccessStatusCode();
var data = await response.Content.ReadAsStringAsync();