mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-03-02 11:44:32 +00:00
Fixed: UI not updating on upgrade
(cherry picked from commit d566c1efd42f9a94c524db311e8fa99bc6e0323f)
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Readarr.Http.Middleware
|
||||
{
|
||||
if (context.Request.Method != "OPTIONS")
|
||||
{
|
||||
if (_cacheableSpecification.IsCacheable(context))
|
||||
if (_cacheableSpecification.IsCacheable(context.Request))
|
||||
{
|
||||
context.Response.Headers.EnableCache();
|
||||
}
|
||||
|
||||
@@ -7,26 +7,26 @@ namespace Readarr.Http.Middleware
|
||||
{
|
||||
public interface ICacheableSpecification
|
||||
{
|
||||
bool IsCacheable(HttpContext context);
|
||||
bool IsCacheable(HttpRequest request);
|
||||
}
|
||||
|
||||
public class CacheableSpecification : ICacheableSpecification
|
||||
{
|
||||
public bool IsCacheable(HttpContext context)
|
||||
public bool IsCacheable(HttpRequest request)
|
||||
{
|
||||
if (!RuntimeInfo.IsProduction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Request.Query.ContainsKey("h"))
|
||||
if (request.Query.ContainsKey("h"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (context.Request.Path.StartsWithSegments("/api", StringComparison.CurrentCultureIgnoreCase))
|
||||
if (request.Path.StartsWithSegments("/api", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
if (context.Request.Path.ToString().ContainsIgnoreCase("/MediaCover"))
|
||||
if (request.Path.ToString().ContainsIgnoreCase("/MediaCover"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -34,40 +34,32 @@ namespace Readarr.Http.Middleware
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Request.Path.StartsWithSegments("/signalr", StringComparison.CurrentCultureIgnoreCase))
|
||||
if (request.Path.StartsWithSegments("/signalr", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Request.Path.Value?.EndsWith("/index.js") ?? false)
|
||||
if (request.Path.Value?.EndsWith("/index.js") ?? false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Request.Path.Value?.EndsWith("/initialize.js") ?? false)
|
||||
if (request.Path.Value?.EndsWith("/initialize.js") ?? false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Request.Path.StartsWithSegments("/feed", StringComparison.CurrentCultureIgnoreCase))
|
||||
if (request.Path.StartsWithSegments("/feed", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Request.Path.StartsWithSegments("/log", StringComparison.CurrentCultureIgnoreCase) &&
|
||||
(context.Request.Path.Value?.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase) ?? false))
|
||||
if (request.Path.StartsWithSegments("/log", StringComparison.CurrentCultureIgnoreCase) &&
|
||||
(request.Path.Value?.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase) ?? false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.Response != null)
|
||||
{
|
||||
if (context.Response.ContentType?.Contains("text/html") ?? false || context.Response.StatusCode >= 400)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Readarr.Http.Middleware
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
if (_cacheableSpecification.IsCacheable(context) && context.Request.Headers["IfModifiedSince"].Any())
|
||||
if (_cacheableSpecification.IsCacheable(context.Request) && context.Request.Headers["IfModifiedSince"].Any())
|
||||
{
|
||||
context.Response.StatusCode = 304;
|
||||
context.Response.Headers.EnableCache();
|
||||
|
||||
Reference in New Issue
Block a user