cachecontrol – github.com/pquerna/cachecontrol Index | Files | Directories

package cachecontrol

import "github.com/pquerna/cachecontrol"

Package cachecontrol implements the logic for HTTP Caching

Deciding if an HTTP Response can be cached is often harder and more bug prone than an actual cache storage backend. cachecontrol provides a simple interface to determine if request and response pairs are cachable as defined under RFC 7234 http://tools.ietf.org/html/rfc7234

Index

Functions

func CachableResponse

func CachableResponse(req *http.Request,
	resp *http.Response,
	opts Options) ([]cacheobject.Reason, time.Time, error)

Given an HTTP Request and Response, determine the possible reasons a response SHOULD NOT be cached.

func CachableResponseWriter

func CachableResponseWriter(req *http.Request,
	statusCode int,
	resp http.ResponseWriter,
	opts Options) ([]cacheobject.Reason, time.Time, error)

Given an HTTP Request, the future Status Code, and an ResponseWriter, determine the possible reasons a response SHOULD NOT be cached.

Types

type Options

type Options struct {
	// Set to True for a private cache, which is not shared among users (eg, in a browser)
	// Set to False for a "shared" cache, which is more common in a server context.
	PrivateCache bool
}

Source Files

api.go doc.go

Directories

PathSynopsis
cacheobject
examples
examples/lowlevel
Version
v0.2.0 (latest)
Published
Apr 15, 2023
Platform
darwin/amd64
Imports
3 packages
Last checked
now

Tools for package owners.