Help us shape the future of Go! Take the 2026 Go Developer Survey

httpcache

package
v0.153.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	RespectCacheControlNoStoreInRequest:  true,
	RespectCacheControlNoStoreInResponse: false,
	Cache: Cache{
		For: GlobMatcher{
			Excludes: []string{"**"},
		},
	},
	Polls: []PollConfig{
		{
			For: GlobMatcher{
				Includes: []string{"**"},
			},
			Disable: true,
		},
	},
}

DefaultConfig holds the default configuration for the HTTP cache.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// Enable HTTP cache behavior (RFC 9111) for these resources.
	For GlobMatcher
}

type Config

type Config struct {
	// When enabled and there's a Cache-Control: no-store directive in the request, response will never be stored in disk cache.
	RespectCacheControlNoStoreInRequest bool

	// When enabled and there's a Cache-Control: no-store directive in the response, response will never be stored in disk cache.
	RespectCacheControlNoStoreInResponse bool

	// Enables HTTP cache behavior (RFC 9111) for these resources.
	// When this is not enabled for a resource, Hugo will go straight to the file cache.
	Cache Cache

	// Polls holds a list of configurations for polling remote resources to detect changes in watch mode.
	// This can be disabled for some resources, typically if they are known to not change.
	Polls []PollConfig
}

Config holds the configuration for the HTTP cache.

func DecodeConfig

func DecodeConfig(_ config.BaseConfig, m map[string]any) (Config, error)

func (*Config) Compile

func (c *Config) Compile() (ConfigCompiled, error)

type ConfigCompiled

type ConfigCompiled struct {
	Base        Config
	For         predicate.P[string]
	PollConfigs []PollConfigCompiled
}

func (*ConfigCompiled) IsPollingDisabled

func (c *ConfigCompiled) IsPollingDisabled() bool

func (*ConfigCompiled) PollConfigFor

func (c *ConfigCompiled) PollConfigFor(s string) PollConfigCompiled

type GlobMatcher

type GlobMatcher struct {
	// Excludes holds a list of glob patterns that will be excluded.
	Excludes []string

	// Includes holds a list of glob patterns that will be included.
	Includes []string
}

func (*GlobMatcher) CompilePredicate

func (gm *GlobMatcher) CompilePredicate() (func(string) bool, error)

func (GlobMatcher) IsZero

func (gm GlobMatcher) IsZero() bool

type PollConfig

type PollConfig struct {
	// What remote resources to apply this configuration to.
	For GlobMatcher

	// Disable polling for this configuration.
	Disable bool

	// Low is the lower bound for the polling interval.
	// This is the starting point when the resource has recently changed,
	// if that resource stops changing, the polling interval will gradually increase towards High.
	Low time.Duration

	// High is the upper bound for the polling interval.
	// This is the interval used when the resource is stable.
	High time.Duration
}

PollConfig holds the configuration for polling remote resources to detect changes in watch mode.

func (PollConfig) MarshalJSON

func (c PollConfig) MarshalJSON() (b []byte, err error)

type PollConfigCompiled

type PollConfigCompiled struct {
	For    predicate.P[string]
	Config PollConfig
}

func (PollConfigCompiled) IsZero

func (p PollConfigCompiled) IsZero() bool

Jump to

Keyboard shortcuts

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