1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/// Diagnostic header indicating cache lookup outcome (`HIT`, `MISS`, or `BYPASS`).
pub const HEADER_X_CACHE: &str = "x-cache";
/// `X-Cache` value emitted when served directly from cache.
pub const X_CACHE_HIT: &str = "HIT";
/// `X-Cache` value emitted when computed by the origin handler.
pub const X_CACHE_MISS: &str = "MISS";
/// `X-Cache` value emitted when caching is bypassed by policy or headers.
pub const X_CACHE_BYPASS: &str = "BYPASS";
/// Default response cache TTL in milliseconds (60 seconds).
pub const DEFAULT_CACHE_TTL_MS: u64 = 60_000;
/// Default maximum cached response count across all shards.
pub const DEFAULT_CACHE_MAX_ENTRIES: usize = 16_384;
/// Default maximum total cached byte budget (64 MiB).
pub const DEFAULT_CACHE_MAX_BYTES: usize = 64 * 1024 * 1024;
/// Default maximum single response body eligible for HTTP response caching (1 MiB).
pub const DEFAULT_CACHE_MAX_ENTRY_BYTES: usize = 1024 * 1024;
/// Number of independent cache shards (`64`, power of two).
pub const CACHE_SHARD_COUNT: usize = 64;
/// Maximum decimal digit buffer capacity for stack formatting a `u64` `Age` header value.
pub const AGE_STACK_BUF_LEN: usize = 20;
/// Maximum prebuilt HTTP/1.1 cache hit response length assembled on the stack without heap allocation.
pub const CACHE_WIRE_STACK_CAP: usize = 4096;
/// FNV-1a 64-bit offset basis used for fast cache shard selection.
pub const CACHE_FNV1A_OFFSET_BASIS: u64 = 0xcbf2_9ce4_8422_2325;
/// FNV-1a 64-bit prime multiplier used for fast cache shard selection.
pub const CACHE_FNV1A_PRIME: u64 = 0x0000_0100_0000_01b3;
/// Prebuilt HTTP/1.1 diagnostic header block inserted before the decimal `Age` value.
pub const CACHE_WIRE_DIAG_PREFIX: & = b"x-cache: HIT\r\nage: ";
/// CRLF separator terminating HTTP/1.1 headers.
pub const CACHE_WIRE_CRLF: & = b"\r\n";
/// Double-CRLF sequence separating HTTP/1.1 headers from the response body.
pub const CACHE_WIRE_HEADER_END: & = b"\r\n\r\n";
/// Context attribute key passing the computed HTTP cache key from request hook to response hook.
pub const ATTR_HTTP_CACHE_KEY: &str = "hyperlane_plugin_cache_key";
/// `Cache-Control` directive prohibiting storing a response.
pub const CC_NO_STORE: &str = "no-store";
/// `Cache-Control` directive prohibiting unvalidated reuse.
pub const CC_NO_CACHE: &str = "no-cache";
/// `Cache-Control` directive marking a response private to a single user.
pub const CC_PRIVATE: &str = "private";
/// `Cache-Control` `max-age=` prefix.
pub const CC_MAX_AGE_PREFIX: &str = "max-age=";
/// `Cache-Control` `s-maxage=` prefix.
pub const CC_S_MAXAGE_PREFIX: &str = "s-maxage=";