1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 01:27:00 +00:00

app.js is no longer cached.

This commit is contained in:
kay.one 2013-07-13 21:19:36 -07:00
parent 8f9b9c901c
commit 0f52a5de22
3 changed files with 36 additions and 11 deletions

View 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();
}
}
}

View file

@ -19,14 +19,17 @@ public class StaticResourceProvider : IProcessStaticResource
{
private readonly IDiskProvider _diskProvider;
private readonly IEnumerable<IMapHttpRequestsToDisk> _requestMappers;
private readonly IAddCacheHeaders _addCacheHeaders;
private readonly Logger _logger;
public StaticResourceProvider(IDiskProvider diskProvider,
IEnumerable<IMapHttpRequestsToDisk> requestMappers,
IAddCacheHeaders addCacheHeaders,
Logger logger)
{
_diskProvider = diskProvider;
_requestMappers = requestMappers;
_addCacheHeaders = addCacheHeaders;
_logger = logger;
}
@ -48,18 +51,8 @@ public Response ProcessStaticResourceRequest(NancyContext context, string workin
if (_diskProvider.FileExists(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;
}

View file

@ -106,6 +106,7 @@
<Compile Include="Episodes\EpisodeResource.cs" />
<Compile Include="Extensions\GZipPipeline.cs" />
<Compile Include="Extensions\NancyJsonSerializer.cs" />
<Compile Include="Frontend\IAddCacheHeaders.cs" />
<Compile Include="Frontend\MediaCoverMapper.cs" />
<Compile Include="Frontend\IMapHttpRequestsToDisk.cs" />
<Compile Include="Frontend\IndexModule.cs" />