CacheableOptions Class
Definition
- Namespace
- Cuemon.AspNetCore.Http.Headers
- Assemblies
- Cuemon.AspNetCore.dll
Configuration options for CacheableMiddleware.
public class CacheableOptions : IValidatableParameterObject, IParameterObject
- Inheritance
-
CacheableOptions
- Implements
Examples
The following example shows how to configure CacheableOptions with cache-control and expiration headers. After validation, it prints whether each header type is enabled.
using System;
using Microsoft.Net.Http.Headers;
namespace Cuemon.AspNetCore.Http.Headers;
public static class CacheableOptionsExample
{
public static void Demonstrate()
{
var options = new CacheableOptions
{
CacheControl = new CacheControlHeaderValue
{
Public = true,
MaxAge = TimeSpan.FromHours(12)
},
Expires = new ExpiresHeaderValue(TimeSpan.FromHours(12))
};
options.ValidateOptions();
Console.WriteLine($"{options.UseCacheControl}:{options.UseExpires}");
}
}
Constructors
| Name | Description |
|---|---|
| CacheableOptions() | Initializes a new instance of the CacheableOptions class. |
Properties
| Name | Description |
|---|---|
| CacheControl | Gets or sets the Cache-Control header associated with a HTTP response. |
| Expires | Gets or sets the Expires header associated with a HTTP response. |
| UseCacheControl | Gets a value indicating whether this instance has an assigned CacheControl value. |
| UseExpires | Gets a value indicating whether this instance has an assigned Expires value. |
| Validators | Gets the validators that will be invoked one by one in InvokeAsync(HttpContext). |
Methods
| Name | Description |
|---|---|
| ValidateOptions() | Determines whether the public read-write properties of this instance are in a valid state. |