mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add cache policy to images
This commit is contained in:
parent
0a38fdd8d3
commit
be076616cc
@ -68,6 +68,14 @@ namespace Kyoo.Core.Api
|
||||
string path = _thumbs.GetImagePath(resource, image, quality ?? ImageQuality.High);
|
||||
if (path == null || !System.IO.File.Exists(path))
|
||||
return NotFound();
|
||||
|
||||
if (!identifier.Match(id => false, slug => slug == "random"))
|
||||
{
|
||||
// Allow clients to cache the image for 6 month.
|
||||
Response.Headers.Add("Cache-Control", $"public, max-age={60 * 60 * 24 * 31 * 6}");
|
||||
}
|
||||
else
|
||||
Response.Headers.Add("Cache-Control", $"public, no-store");
|
||||
return PhysicalFile(Path.GetFullPath(path), "image/webp", true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user