Skip to main content

hyperlane_plugin_cache/
const.rs

1/// Diagnostic header indicating cache lookup outcome (`HIT`, `MISS`, or `BYPASS`).
2pub const HEADER_X_CACHE: &str = "x-cache";
3
4/// `X-Cache` value emitted when served directly from cache.
5pub const X_CACHE_HIT: &str = "HIT";
6
7/// `X-Cache` value emitted when computed by the origin handler.
8pub const X_CACHE_MISS: &str = "MISS";
9
10/// `X-Cache` value emitted when caching is bypassed by policy or headers.
11pub const X_CACHE_BYPASS: &str = "BYPASS";
12
13/// Default response cache TTL in milliseconds (60 seconds).
14pub const DEFAULT_CACHE_TTL_MS: u64 = 60_000;
15
16/// Default maximum cached response count across all shards.
17pub const DEFAULT_CACHE_MAX_ENTRIES: usize = 16_384;
18
19/// Default maximum total cached byte budget (64 MiB).
20pub const DEFAULT_CACHE_MAX_BYTES: usize = 64 * 1024 * 1024;
21
22/// Default maximum single response body eligible for HTTP response caching (1 MiB).
23pub const DEFAULT_CACHE_MAX_ENTRY_BYTES: usize = 1024 * 1024;
24
25/// Number of independent cache shards (`64`, power of two).
26pub(crate) const CACHE_SHARD_COUNT: usize = 64;
27
28/// Context attribute key passing the computed HTTP cache key from request hook to response hook.
29pub(crate) const ATTR_HTTP_CACHE_KEY: &str = "hyperlane_plugin_cache_key";
30
31/// `Cache-Control` directive prohibiting storing a response.
32pub(crate) const CC_NO_STORE: &str = "no-store";
33
34/// `Cache-Control` directive prohibiting unvalidated reuse.
35pub(crate) const CC_NO_CACHE: &str = "no-cache";
36
37/// `Cache-Control` directive marking a response private to a single user.
38pub(crate) const CC_PRIVATE: &str = "private";
39
40/// `Cache-Control` `max-age=` prefix.
41pub(crate) const CC_MAX_AGE_PREFIX: &str = "max-age=";
42
43/// `Cache-Control` `s-maxage=` prefix.
44pub(crate) const CC_S_MAXAGE_PREFIX: &str = "s-maxage=";