cachecontrol

package module
v0.0.0-...-032b08a Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 5 Imported by: 0

README

Cache Control

Tool for a setting Cache-Control in a comfortable way.

Documentation

Overview

Cache Control is a package to provide a flexible control over Cache-Control header.

Please note, this package is not going to cover all the Cache-Control functionality.

Index

Constants

This section is empty.

Variables

View Source
var DefaultPage = &Configuration{
	Type:    zen.Ptr(Public),
	MaxAge:  zen.Ptr(0 * time.Hour),
	SMaxAge: zen.Ptr(12 * time.Hour),
}
View Source
var DefaultStatic = &Configuration{
	Type:   zen.Ptr(Public),
	MaxAge: zen.Ptr(12 * time.Hour),
}

Functions

func MiddlewarePage

func MiddlewarePage(next http.HandlerFunc, control *Configuration) http.HandlerFunc

func Set

func Set(w http.ResponseWriter, r *http.Request, control *Configuration)

Set writes a cache-control header according to provided configuration. Prints warnings about conflicts and misuses.

Types

type CacheType

type CacheType int
const (
	Public CacheType = iota
	Private
	Immutable
	NoCache
	NoStore
)

func (CacheType) String

func (c CacheType) String() string

type Configuration

type Configuration struct {
	Type    *CacheType
	MaxAge  *time.Duration
	SMaxAge *time.Duration
}

Jump to

Keyboard shortcuts

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