Setting no cache values to video files

This commit is contained in:
Zoe Roux 2021-01-14 23:52:20 +01:00
parent 50aaeff7da
commit 1bb2b27edc

View File

@ -5,13 +5,14 @@ using Microsoft.Extensions.Configuration;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.StaticFiles;
namespace Kyoo.Api
{
[Route("video")]
[ApiController]
public class VideoApi : ControllerBase
public class VideoApi : Controller
{
private readonly ILibraryManager _libraryManager;
private readonly ITranscoder _transcoder;
@ -27,6 +28,14 @@ namespace Kyoo.Api
_transcodePath = config.GetValue<string>("transcodeTempPath");
}
public override void OnActionExecuted(ActionExecutedContext ctx)
{
base.OnActionExecuted(ctx);
ctx.HttpContext.Response.Headers.Add("Cache-Control", "no-cache, no-store, must-revalidate");
ctx.HttpContext.Response.Headers.Add("Pragma", "no-cache");
ctx.HttpContext.Response.Headers.Add("Expires", "0");
}
private string _GetContentType(string path)
{
if (_provider == null)