2013-08-20 05:31:26 +03:00
|
|
|
using System;
|
|
|
|
using Nancy;
|
2013-08-20 08:53:18 +03:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-08-20 05:31:26 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Api.Frontend
|
|
|
|
{
|
2013-08-20 08:53:18 +03:00
|
|
|
public interface ICacheableSpecification
|
2013-08-20 05:31:26 +03:00
|
|
|
{
|
2013-08-20 08:53:18 +03:00
|
|
|
bool IsCacheable(NancyContext context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CacheableSpecification : ICacheableSpecification
|
|
|
|
{
|
|
|
|
public bool IsCacheable(NancyContext context)
|
2013-08-20 05:31:26 +03:00
|
|
|
{
|
2013-08-20 08:53:18 +03: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 05:31:26 +03:00
|
|
|
|
2013-08-20 08:53:18 +03:00
|
|
|
if (context.Response != null)
|
|
|
|
{
|
|
|
|
if (context.Response.ContentType.Contains("text/html")) return false;
|
|
|
|
}
|
2013-08-20 05:31:26 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|