mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-26 09:37:12 +00:00
app.js is no longer cached.
This commit is contained in:
parent
8f9b9c901c
commit
0f52a5de22
3 changed files with 36 additions and 11 deletions
31
NzbDrone.Api/Frontend/IAddCacheHeaders.cs
Normal file
31
NzbDrone.Api/Frontend/IAddCacheHeaders.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
using Nancy;
|
||||||
|
using NzbDrone.Api.Extensions;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Frontend
|
||||||
|
{
|
||||||
|
public interface IAddCacheHeaders
|
||||||
|
{
|
||||||
|
void ToResponse(Request request, Response response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AddCacheHeaders : IAddCacheHeaders
|
||||||
|
{
|
||||||
|
public void ToResponse(Request request, Response response)
|
||||||
|
{
|
||||||
|
if (!RuntimeInfo.IsProduction)
|
||||||
|
{
|
||||||
|
response.Headers.DisableCache();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.Url.Path.ToLower() == "app.js")
|
||||||
|
{
|
||||||
|
response.Headers.DisableCache();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
response.Headers.EnableCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,14 +19,17 @@ public class StaticResourceProvider : IProcessStaticResource
|
||||||
{
|
{
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
private readonly IEnumerable<IMapHttpRequestsToDisk> _requestMappers;
|
private readonly IEnumerable<IMapHttpRequestsToDisk> _requestMappers;
|
||||||
|
private readonly IAddCacheHeaders _addCacheHeaders;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public StaticResourceProvider(IDiskProvider diskProvider,
|
public StaticResourceProvider(IDiskProvider diskProvider,
|
||||||
IEnumerable<IMapHttpRequestsToDisk> requestMappers,
|
IEnumerable<IMapHttpRequestsToDisk> requestMappers,
|
||||||
|
IAddCacheHeaders addCacheHeaders,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_requestMappers = requestMappers;
|
_requestMappers = requestMappers;
|
||||||
|
_addCacheHeaders = addCacheHeaders;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,18 +51,8 @@ public Response ProcessStaticResourceRequest(NancyContext context, string workin
|
||||||
if (_diskProvider.FileExists(filePath))
|
if (_diskProvider.FileExists(filePath))
|
||||||
{
|
{
|
||||||
var response = new StreamResponse(() => File.OpenRead(filePath), MimeTypes.GetMimeType(filePath));
|
var response = new StreamResponse(() => File.OpenRead(filePath), MimeTypes.GetMimeType(filePath));
|
||||||
|
_addCacheHeaders.ToResponse(context.Request, response);
|
||||||
|
|
||||||
if (RuntimeInfo.IsProduction)
|
|
||||||
{
|
|
||||||
response.Headers.EnableCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
response.Headers.DisableCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
//return response.CompressResponse(context.Request);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
<Compile Include="Episodes\EpisodeResource.cs" />
|
<Compile Include="Episodes\EpisodeResource.cs" />
|
||||||
<Compile Include="Extensions\GZipPipeline.cs" />
|
<Compile Include="Extensions\GZipPipeline.cs" />
|
||||||
<Compile Include="Extensions\NancyJsonSerializer.cs" />
|
<Compile Include="Extensions\NancyJsonSerializer.cs" />
|
||||||
|
<Compile Include="Frontend\IAddCacheHeaders.cs" />
|
||||||
<Compile Include="Frontend\MediaCoverMapper.cs" />
|
<Compile Include="Frontend\MediaCoverMapper.cs" />
|
||||||
<Compile Include="Frontend\IMapHttpRequestsToDisk.cs" />
|
<Compile Include="Frontend\IMapHttpRequestsToDisk.cs" />
|
||||||
<Compile Include="Frontend\IndexModule.cs" />
|
<Compile Include="Frontend\IndexModule.cs" />
|
||||||
|
|
Loading…
Reference in a new issue