diff --git a/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckMiddleware.cs b/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckMiddleware.cs index 2e1897b..ba6b870 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckMiddleware.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckMiddleware.cs @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Diagnostics.HealthChecks 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 var headers = httpContext.Response.Headers; diff --git a/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckOptions.cs b/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckOptions.cs index d66a59e..bf43676 100644 --- a/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckOptions.cs +++ b/src/Microsoft.AspNetCore.Diagnostics.HealthChecks/HealthCheckOptions.cs @@ -48,11 +48,19 @@ namespace Microsoft.AspNetCore.Diagnostics.HealthChecks public Func ResponseWriter { get; set; } = HealthCheckResponseWriters.WriteMinimalPlaintext; /// - /// Gets or sets a value that controls whether the health check middleware will add HTTP headers to prevent - /// response caching. If the value is false the health check middleware will set or override the + /// Gets or sets a value that controls whether responses from the health check middleware can be cached. + /// + /// + /// + /// 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. + /// + /// + /// If the value is false the health check middleware will set or override the /// Cache-Control, Expires, and Pragma headers to prevent response caching. If the value /// is true the health check middleware will not modify the cache headers of the response. - /// - public bool SuppressCacheHeaders { get; set; } + /// + /// + public bool AllowCachingResponses { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests/HealthCheckMiddlewareTests.cs b/test/Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests/HealthCheckMiddlewareTests.cs index 7dab1cc..a3036f9 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests/HealthCheckMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests/HealthCheckMiddlewareTests.cs @@ -324,7 +324,7 @@ namespace Microsoft.AspNetCore.Diagnostics.HealthChecks { app.UseHealthChecks("/health", new HealthCheckOptions() { - SuppressCacheHeaders = true, + AllowCachingResponses = true, }); }) .ConfigureServices(services =>