v1.6.49 Latest Latest

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 11 Imported by: 11




View Source
const (
	StoredTTLHeader    = "X-Souin-Stored-TTL"
	StoredLengthHeader = "X-Souin-Stored-Length"
View Source
const (
	VarySeparator          = "{-VARY-}"
	DecodedHeaderSeparator = ";"


This section is empty.


func GetCacheKeyFromCtx

func GetCacheKeyFromCtx(currentCtx ctx.Context) string

func GetVariedCacheKey

func GetVariedCacheKey(rq *http.Request, headers []string) string

GetVariedCacheKey returns the varied cache key for req and resp.

func HeaderAllCommaSepValues

func HeaderAllCommaSepValues(headers http.Header, headerName string) []string

HeaderAllCommaSepValues returns all comma-separated values (each with whitespace trimmed) for a given header name. According to Section 4.2 of the HTTP/1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2), values from multiple occurrences of a header should be concatenated, if the header's value is a comma-separated list.

func HeaderAllCommaSepValuesString added in v1.6.46

func HeaderAllCommaSepValuesString(headers http.Header, headerName string) string

func HitStaleCache

func HitStaleCache(h *http.Header)

HitStaleCache set hit and stale in the Cache-Status header

func SetCacheStatusHeader

func SetCacheStatusHeader(resp *http.Response) *http.Response

SetCacheStatusHeader set the Cache-Status header

func SetRequestCacheStatus

func SetRequestCacheStatus(h *http.Header, header, cacheName string)

SetRequestCacheStatus set the Cache-Status fwd=request

func ValidateCacheControl

func ValidateCacheControl(r *http.Response, requestCc *cacheobject.RequestCacheDirectives) bool

ValidateCacheControl check the Cache-Control header

func ValidateETag added in v1.6.38

func ValidateETag(res *http.Response, validator *Revalidator)

func ValidateETagFromHeader added in v1.6.47

func ValidateETagFromHeader(etag string, validator *Revalidator)

func ValidateMaxAgeCachedResponse

func ValidateMaxAgeCachedResponse(co *cacheobject.RequestCacheDirectives, res *http.Response) *http.Response

func ValidateMaxAgeCachedStaleResponse

func ValidateMaxAgeCachedStaleResponse(co *cacheobject.RequestCacheDirectives, res *http.Response, addTime int) *http.Response

func VariedHeaderAllCommaSepValues added in v1.6.45

func VariedHeaderAllCommaSepValues(headers http.Header) ([]string, bool)

VariedHeaderAllCommaSepValues returns all comma-separated values or '*' alone when the header contains it.


type Revalidator added in v1.6.38

type Revalidator struct {
	Matched                     bool
	IfNoneMatchPresent          bool
	IfMatchPresent              bool
	IfModifiedSincePresent      bool
	IfUnmodifiedSincePresent    bool
	IfUnmotModifiedSincePresent bool
	NeedRevalidation            bool
	NotModified                 bool
	IfModifiedSince             time.Time
	IfUnmodifiedSince           time.Time
	IfNoneMatch                 []string
	IfMatch                     []string
	RequestETags                []string
	ResponseETag                string

func ParseRequest added in v1.6.38

func ParseRequest(req *http.Request) *Revalidator

Jump to

Keyboard shortcuts

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