Rename anti-caching option
- Renamed the property for configuration response caching headers - Renamed the options class to avoid conflicts with other type names Fixes https://github.com/aspnet/Diagnostics/issues/509
This commit is contained in:
parent
1afd5b2594
commit
4c94bc272b
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Diagnostics.HealthChecks
|
||||||
|
|
||||||
httpContext.Response.StatusCode = statusCode;
|
httpContext.Response.StatusCode = statusCode;
|
||||||
|
|
||||||
if (!_healthCheckOptions.SuppressCacheHeaders)
|
if (!_healthCheckOptions.AllowCachingResponses)
|
||||||
{
|
{
|
||||||
// Similar to: https://github.com/aspnet/Security/blob/7b6c9cf0eeb149f2142dedd55a17430e7831ea99/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs#L377-L379
|
// Similar to: https://github.com/aspnet/Security/blob/7b6c9cf0eeb149f2142dedd55a17430e7831ea99/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs#L377-L379
|
||||||
var headers = httpContext.Response.Headers;
|
var headers = httpContext.Response.Headers;
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,19 @@ namespace Microsoft.AspNetCore.Diagnostics.HealthChecks
|
||||||
public Func<HttpContext, HealthReport, Task> ResponseWriter { get; set; } = HealthCheckResponseWriters.WriteMinimalPlaintext;
|
public Func<HttpContext, HealthReport, Task> ResponseWriter { get; set; } = HealthCheckResponseWriters.WriteMinimalPlaintext;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value that controls whether the health check middleware will add HTTP headers to prevent
|
/// Gets or sets a value that controls whether responses from the health check middleware can be cached.
|
||||||
/// response caching. If the value is <c>false</c> the health check middleware will set or override the
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// The health check middleware does not perform caching of any kind. This setting configures whether
|
||||||
|
/// the middleware will apply headers to the HTTP response that instruct clients to avoid caching.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// If the value is <c>false</c> the health check middleware will set or override the
|
||||||
/// <c>Cache-Control</c>, <c>Expires</c>, and <c>Pragma</c> headers to prevent response caching. If the value
|
/// <c>Cache-Control</c>, <c>Expires</c>, and <c>Pragma</c> headers to prevent response caching. If the value
|
||||||
/// is <c>true</c> the health check middleware will not modify the cache headers of the response.
|
/// is <c>true</c> the health check middleware will not modify the cache headers of the response.
|
||||||
/// </summary>
|
/// </para>
|
||||||
public bool SuppressCacheHeaders { get; set; }
|
/// </remarks>
|
||||||
|
public bool AllowCachingResponses { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ namespace Microsoft.AspNetCore.Diagnostics.HealthChecks
|
||||||
{
|
{
|
||||||
app.UseHealthChecks("/health", new HealthCheckOptions()
|
app.UseHealthChecks("/health", new HealthCheckOptions()
|
||||||
{
|
{
|
||||||
SuppressCacheHeaders = true,
|
AllowCachingResponses = true,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.ConfigureServices(services =>
|
.ConfigureServices(services =>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue