headers

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package headers provides HTTP caching utilities and response header helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheKeyForPath added in v1.3.0

func CacheKeyForPath(urlPath, indexFile string) string

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

func ETagMatches(ifNoneMatch, etag string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL