Skip to main content

Module cache

Module cache 

Source
Expand description

Cache-Control (RFC 9111 section 5.2, with immutable from RFC 8246 and stale-while-revalidate and stale-if-error from RFC 5861).

§Examples

use parse_net::{self as pn, cache::Writer};

let cc = pn::response_cache_control(b"public, max-age=\"60\", MAX-AGE=5, x-ext=1")?;
assert_eq!((cc.public, cc.max_age, cc.duplicates, cc.unknown), (true, Some(60), true, 1));

let mut buf = [0u8; 64];
let mut out = pn::SliceSink::new(&mut buf);
Writer::new(&mut out).flag("public").and_then(|w| w.seconds("max-age", 60)).expect("room");
assert_eq!(out.written(), b"public, max-age=60");

Structs§

Directive
One directive: a name and an optional argument.
Directives
Validated directives.
RequestDirectives
The request directives (RFC 9111 section 5.2.1).
ResponseDirectives
The response directives (RFC 9111 section 5.2.2 and the extensions).
Writer
Writes Cache-Control directives, separated by , .

Functions§

parse
Parses #( token [ "=" ( token / quoted-string ) ] ), keeping every directive raw.
request_cache_control
Reads a request Cache-Control value.
request_lines
Reads several request Cache-Control field lines as one.
response_cache_control
Reads a response Cache-Control value.
response_lines
Reads several response Cache-Control field lines as one.