cacheobj

package
v5.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanReuse

func CanReuse(
	reqHeader http.Header,
	reqCacheControl rfc.CacheControlMap,
	cacheObj *CacheObj,
	strictRFC bool,
	revalidateCanReuse bool,
) bool

CanReuse is a helper wrapping github.com/apache/trafficcontrol/lib/go-rfc.CanReuseStored, returning a boolean rather than an enumerated "Reuse" value, for when it's known whether MustRevalidate can be used.

Types

type CacheObj

type CacheObj struct {
	Body             []byte
	ReqHeaders       http.Header
	RespHeaders      http.Header
	RespCacheControl rfc.CacheControlMap
	Code             int
	OriginCode       int
	ProxyURL         string
	ReqTime          time.Time // our client's time when the object was requested
	ReqRespTime      time.Time // our client's time when the object was received
	RespRespTime     time.Time // the origin server's Date time when the object was sent
	LastModified     time.Time // the origin LastModified if it exists, or Date if it doesn't
	Size             uint64
	HitCount         uint64 // the number of times this object was hit
}

func New

func New(reqHeader http.Header, bytes []byte, code int, originCode int, proxyURL string, respHeader http.Header, reqTime time.Time, reqRespTime time.Time, respRespTime time.Time, lastModified time.Time) *CacheObj

func (CacheObj) ComputeSize

func (c CacheObj) ComputeSize() uint64

ComputeSize computes the size of the given CacheObj. This computation is expensive, as the headers must be iterated over. Thus, the size should be computed once and stored, not computed on-the-fly for every new request for the cached object.

Jump to

Keyboard shortcuts

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