1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00
Radarr/NzbDrone.Api/Frontend/IsCacheableSpecification.cs

35 lines
1016 B
C#
Raw Normal View History

using System;
using Nancy;
2013-08-20 07:53:18 +02:00
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Api.Frontend
{
2013-08-20 07:53:18 +02:00
public interface ICacheableSpecification
{
2013-08-20 07:53:18 +02:00
bool IsCacheable(NancyContext context);
}
public class CacheableSpecification : ICacheableSpecification
{
public bool IsCacheable(NancyContext context)
{
2013-08-21 08:28:41 +02:00
if (BuildInfo.IsDebug)
{
return false;
}
2013-08-20 07:53:18 +02:00
if (context.Request.Query.v == BuildInfo.Version) return true;
if (context.Request.Path.StartsWith("/api", StringComparison.CurrentCultureIgnoreCase)) return false;
if (context.Request.Path.StartsWith("/signalr", StringComparison.CurrentCultureIgnoreCase)) return false;
if (context.Request.Path.EndsWith("app.js")) return false;
2013-08-20 07:53:18 +02:00
if (context.Response != null)
{
if (context.Response.ContentType.Contains("text/html")) return false;
}
return true;
}
}
}