Documentation
¶
Overview ¶
Package headers provides HTTP caching utilities and response header helpers.
Index ¶
- func CacheKeyForPath(urlPath, indexFile string) string
- func CheckNotModified(ctx *fasthttp.RequestCtx, f *cache.CachedFile) bool
- func ETagMatches(ifNoneMatch, etag string) bool
- func SetCacheHeaders(ctx *fasthttp.RequestCtx, urlPath string, f *cache.CachedFile, ...)
- func SetFileHeaders(ctx *fasthttp.RequestCtx, urlPath string, f *cache.CachedFile, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheKeyForPath ¶ added in v1.3.0
CacheKeyForPath normalises a URL path to the cache key used by the file handler. Directory paths (trailing slash, or bare "/") are mapped to their index file so that 304 checks succeed for index requests. PERF-005: fast-path for the common "/" → "/index.html" case.
func CheckNotModified ¶ added in v1.3.0
func CheckNotModified(ctx *fasthttp.RequestCtx, f *cache.CachedFile) bool
CheckNotModified evaluates conditional request headers. Returns true and writes a 304 response if the resource has not changed. Uses pre-formatted header strings when available (PERF-003).
func ETagMatches ¶ added in v1.3.0
ETagMatches reports whether the If-None-Match value matches the given etag. It supports the wildcard "*" and a comma-separated list of tags. Uses zero-alloc IndexByte walking instead of strings.Split (PERF-006).
func SetCacheHeaders ¶ added in v1.3.0
func SetCacheHeaders(ctx *fasthttp.RequestCtx, urlPath string, f *cache.CachedFile, cfg *config.HeadersConfig)
SetCacheHeaders writes ETag, Last-Modified, Cache-Control, and Vary headers. When the CachedFile has pre-formatted header strings (from InitHeaders + InitCacheControl), they are assigned directly, bypassing string formatting entirely (PERF-003).
func SetFileHeaders ¶
func SetFileHeaders(ctx *fasthttp.RequestCtx, urlPath string, f *cache.CachedFile, cfg *config.HeadersConfig)
SetFileHeaders writes caching headers for a file response.
Types ¶
This section is empty.