storage

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyNegativeTTL added in v1.3.1

func ApplyNegativeTTL(status int, negativeTTL map[int]int, defaultTTL time.Duration) time.Duration

ApplyNegativeTTL - Overrides the TTL for a configured status (e.g. 404/502) with its own short TTL instead of inheriting origin cache headers, which error pages rarely set sanely. This shields the origin from repeated hits on a broken URL.

func PurgeCachedContent

func PurgeCachedContent(ctx context.Context, upstream config.Upstream, rc RequestCallDTO) (bool, error)

PurgeCachedContent - Purges a content in the cache, or everything cached for the host when the request-target is cache.PurgeAllPath.

func RetrieveCachedContent

func RetrieveCachedContent(ctx context.Context, rc RequestCallDTO, logger *log.Entry) (cache.URIObj, error)

RetrieveCachedContent - Retrives the cached response.

func StorageTTL added in v1.4.0

func StorageTTL(uri cache.URIObj, domainConfigCache config.Cache) time.Duration

StorageTTL - Decides the TTL a response is stored with, by precedence:

  1. negative_ttl, for the statuses it lists;
  2. override_ttl, when > 0, replacing any origin freshness information;
  3. s-maxage / max-age / Expires from the origin (see ttl.GetTTL);
  4. ttl, the default when the origin sends no freshness information.

It never makes a response storable: StoreFullPage still refuses what a shared cache must not store (no-store, private, no-cache, Authorization without public/s-maxage/must-revalidate) whatever TTL is returned here.

func StoreGeneratedPage

func StoreGeneratedPage(ctx context.Context, rc RequestCallDTO, domainConfigCache config.Cache) (bool, error)

StoreGeneratedPage - Stores a response in the cache.

Types

type RequestCallDTO

type RequestCallDTO struct {
	ReqID       string
	Response    response.LoggedResponseWriter
	Request     http.Request
	CacheObject cache.Object
}

RequestCallDTO - DTO object containing request and response.

Jump to

Keyboard shortcuts

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