Add cache control for Azure

This commit is contained in:
Caelan Sayler
2024-03-28 09:50:28 +00:00
parent f16bfe5349
commit 44ad132a72

View File

@@ -1,5 +1,7 @@
using Azure.Storage;
using Azure;
using Azure.Storage;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Microsoft.Extensions.Logging;
namespace Velopack.Deployment;
@@ -98,6 +100,15 @@ public class AzureRepository : ObjectRepository<AzureDownloadOptions, AzureUploa
// already exists. storage providers should prefer the newer file of the same name.
}
await RetryAsync(() => blobClient.UploadAsync(f.FullName, overwriteRemote), "Uploading " + key);
var options = new BlobUploadOptions {
HttpHeaders = new BlobHttpHeaders(),
Conditions = overwriteRemote ? null : new BlobRequestConditions { IfNoneMatch = new ETag("*") }
};
if (noCache) {
options.HttpHeaders.CacheControl = "no-cache";
}
await RetryAsync(() => blobClient.UploadAsync(f.FullName, options), "Uploading " + key);
}
}