1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01: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" />