diff --git a/Femto.Api/Controllers/Media/MediaController.cs b/Femto.Api/Controllers/Media/MediaController.cs index 7f0e371..32675ca 100644 --- a/Femto.Api/Controllers/Media/MediaController.cs +++ b/Femto.Api/Controllers/Media/MediaController.cs @@ -31,13 +31,18 @@ public class MediaController(IMediaModule mediaModule) : ControllerBase } [HttpGet("{id}")] - [Authorize] public async Task GetMedia(Guid id, CancellationToken cancellationToken) { var res = await mediaModule.PostQuery(new LoadFileQuery(id), cancellationToken); + // Set cache headers + HttpContext.Response.Headers.CacheControl = "public,max-age=31536000"; // Cache for 1 year + HttpContext.Response.Headers.Expires = DateTime.UtcNow.AddYears(1).ToString("R"); + + // If you want to support cache validation + HttpContext.Response.Headers.ETag = $"\"{id}\""; // Using the file ID as ETag + HttpContext.Response.ContentType = res.Type; HttpContext.Response.ContentLength = res.Size; await res.Data.CopyToAsync(HttpContext.Response.Body, cancellationToken); - } -} + }}