nx_cache_control.nx
buildroot/runtime/nx_cache_control.nx
about
cache_control.nx -- parse HTTP Cache-Control header.
RFC 7234 §5.2. Controls caching behaviour at every level
(browser, proxy, CDN, reverse-proxy). Getting it right is
the difference between a fast site and a stampeded origin.
Format: comma-separated directives, some with arguments.
Cache-Control: max-age=3600, public
Cache-Control: no-store
Cache-Control: private, max-age=0, must-revalidate
Cache-Control: public, max-age=31536000, immutable
Cache-Control: no-cache, s-maxage=600
We parse into a typed CacheControl struct with flag bits for
the named directives + integer values for max-age / s-maxage /
max-stale / min-fresh / stale-while-revalidate.
Invariants:
CC1 Empty input yields default CacheControl (all flags 0,
ages = -1 meaning \"not specified\").
CC2 Unknown directives silently ignored per RFC 7234 §5.2
tolerance rule.
CC3 Directive names are case-insensitive (we lowercase on
match). Argument values are case-sensitive integers.
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 36 | struct CacheControl |
consts
| 33 | const K_MAGIC_3600: i64 = 3600 |
| 34 | const K_MAGIC_31536000: i64 = 31536000 |
functions
| 58 | func cache_control_init(cc: *CacheControl) -> i64 called by 1: cache_control_parse |
| 78 | func cc_lower(b: i64) -> i64 called by 1: cc_eq_ci |
| 86 | func cc_eq_ci(a: *u8, a_off: i64, a_len: i64, |
| 98 | func cc_parse_int(buf: *u8, off: i64, end: i64) -> i64 called by 1: cache_control_parse |
| 116 | func cache_control_parse(buf: *u8, n: i64, cc: *CacheControl) -> i64 |
| 240 | func main() -> i64 |