use api_bones::CacheControl;
fn main() {
let cc = CacheControl::new()
.public()
.max_age(31_536_000) .immutable();
println!("Static asset: {cc}");
assert_eq!(cc.to_string(), "public, immutable, max-age=31536000");
let cc = CacheControl::private_no_cache();
println!("Private API: {cc}");
assert!(cc.private && cc.no_cache && cc.no_store);
let cc = CacheControl::new()
.public()
.max_age(60)
.stale_while_revalidate(30)
.stale_if_error(86_400);
println!("SWR response: {cc}");
let cc = CacheControl::new().only_if_cached().max_stale(300);
println!("Offline req: {cc}");
let cc: CacheControl = "public, max-age=3600, must-revalidate"
.parse()
.expect("valid header");
println!(
"\nParsed: public={} max_age={:?} must_revalidate={}",
cc.public, cc.max_age, cc.must_revalidate
);
assert!(cc.public);
assert_eq!(cc.max_age, Some(3600));
assert!(cc.must_revalidate);
let cc: CacheControl = "no-store".parse().expect("valid header");
assert!(cc.no_store);
println!("no-store parsed: no_store={}", cc.no_store);
println!("\nAll cache_control examples passed.");
}