@ -7,26 +7,26 @@ namespace Radarr.Http.Middleware
{
{
public interface ICacheableSpecification
public interface ICacheableSpecification
{
{
bool IsCacheable ( Http Context contex t) ;
bool IsCacheable ( Http Request reques t) ;
}
}
public class CacheableSpecification : ICacheableSpecification
public class CacheableSpecification : ICacheableSpecification
{
{
public bool IsCacheable ( Http Context contex t)
public bool IsCacheable ( Http Request reques t)
{
{
if ( ! RuntimeInfo . IsProduction )
if ( ! RuntimeInfo . IsProduction )
{
{
return false ;
return false ;
}
}
if ( context. R equest. Query . ContainsKey ( "h" ) )
if ( r equest. Query . ContainsKey ( "h" ) )
{
{
return true ;
return true ;
}
}
if ( context. R equest. Path . StartsWithSegments ( "/api" , StringComparison . CurrentCultureIgnoreCase ) )
if ( r equest. Path . StartsWithSegments ( "/api" , StringComparison . CurrentCultureIgnoreCase ) )
{
{
if ( context. R equest. Path . ToString ( ) . ContainsIgnoreCase ( "/MediaCover" ) )
if ( r equest. Path . ToString ( ) . ContainsIgnoreCase ( "/MediaCover" ) )
{
{
return true ;
return true ;
}
}
@ -34,40 +34,32 @@ namespace Radarr.Http.Middleware
return false ;
return false ;
}
}
if ( context. R equest. Path . StartsWithSegments ( "/signalr" , StringComparison . CurrentCultureIgnoreCase ) )
if ( r equest. Path . StartsWithSegments ( "/signalr" , StringComparison . CurrentCultureIgnoreCase ) )
{
{
return false ;
return false ;
}
}
if ( context. R equest. Path . Value ? . EndsWith ( "/index.js" ) ? ? false )
if ( r equest. Path . Value ? . EndsWith ( "/index.js" ) ? ? false )
{
{
return false ;
return false ;
}
}
if ( context. R equest. Path . Value ? . EndsWith ( "/initialize.js" ) ? ? false )
if ( r equest. Path . Value ? . EndsWith ( "/initialize.js" ) ? ? false )
{
{
return false ;
return false ;
}
}
if ( context. R equest. Path . StartsWithSegments ( "/feed" , StringComparison . CurrentCultureIgnoreCase ) )
if ( r equest. Path . StartsWithSegments ( "/feed" , StringComparison . CurrentCultureIgnoreCase ) )
{
{
return false ;
return false ;
}
}
if ( context. R equest. Path . StartsWithSegments ( "/log" , StringComparison . CurrentCultureIgnoreCase ) & &
if ( r equest. Path . StartsWithSegments ( "/log" , StringComparison . CurrentCultureIgnoreCase ) & &
( context. R equest. Path . Value ? . EndsWith ( ".txt" , StringComparison . CurrentCultureIgnoreCase ) ? ? false ) )
( r equest. Path . Value ? . EndsWith ( ".txt" , StringComparison . CurrentCultureIgnoreCase ) ? ? false ) )
{
{
return false ;
return false ;
}
}
if ( context . Response ! = null )
{
if ( context . Response . ContentType ? . Contains ( "text/html" ) ? ? false | | context . Response . StatusCode > = 400 )
{
return false ;
}
}
return true ;
return true ;
}
}
}
}