[FA-misc] Fixes file caching #47

Merged
conco merged 1 commits from hotfix/FA-misc_FixFileCaching into master 2025-12-10 21:09:53 +00:00
Showing only changes of commit 6fd76f6787 - Show all commits

View File

@@ -35,8 +35,16 @@ namespace FictionArchive.Service.FileService.Controllers
BucketName = _s3Configuration.Bucket, BucketName = _s3Configuration.Bucket,
Key = decodedPath Key = decodedPath
}); });
return new FileStreamResult(s3Response.ResponseStream, s3Response.Headers.ContentType); Response.Headers.CacheControl = "public, max-age=604800"; // 7 days
Response.Headers.LastModified = s3Response.LastModified?.ToString("R");
if (!string.IsNullOrEmpty(s3Response.ETag))
{
Response.Headers.ETag = s3Response.ETag;
}
return File(s3Response.ResponseStream, s3Response.Headers.ContentType);
} }
catch (AmazonS3Exception e) catch (AmazonS3Exception e)
{ {