Skip to main content

Module cache

Module cache 

Source
Expand description

Cache-Control header builder and parser (RFC 7234).

CacheControl represents the structured set of directives that can appear in a Cache-Control HTTP header, with builder methods for the most common request and response directives.

§Example

use api_bones::cache::CacheControl;

// Build a typical immutable public response.
let cc = CacheControl::new()
    .public()
    .max_age(31_536_000)
    .immutable();
assert_eq!(cc.to_string(), "public, immutable, max-age=31536000");

// Parse a header value.
let cc: CacheControl = "no-store, no-cache".parse().unwrap();
assert!(cc.no_store);
assert!(cc.no_cache);

Structs§

CacheControl
Structured Cache-Control header (RFC 7234 §5.2).
ParseCacheControlError
Error returned when parsing a Cache-Control header fails.