Skip to content

The search box in the website knows all the secrets—try it!

For any queries, join our Discord Channel to reach us faster.

JasperFx Logo

JasperFx provides formal support for Wolverine and other JasperFx libraries. Please check our Support Plans for more details.

Caching 5.9

For caching HTTP responses, Wolverine can simply work with the Response Caching Middleware in ASP.NET Core.

Wolverine.HTTP will respect your usage of the [ResponseCache] attribute on either the endpoint handler or method to write out both the vary and cache-control HTTP headers -- with an attribute on the method taking precedence.

Here's an example or two:

cs
// This is all it takes:
[WolverineGet("/cache/one"), ResponseCache(Duration = 3, VaryByHeader = "accept-encoding", NoStore = false)]
public static string GetOne()
{
    return "one";
}

[WolverineGet("/cache/two"), ResponseCache(Duration = 10, NoStore = true)]
public static string GetTwo()
{
    return "two";
}

snippet source | anchor

Wolverine.HTTP will also modify the OpenAPI metadata to reflect the caching as well as embed the metadata in the ASP.Net Core Endpoint for utilization inside of the response caching middleware.

Released under the MIT License.