package httpcache

import "github.com/gohugoio/hugo/cache/httpcache"

Index

Variables

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

DefaultConfig holds the default configuration for the HTTP cache.

Types

type Cache

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

type Config

type Config struct {
	// Configures the HTTP cache behaviour (RFC 9111).
	// 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(bcfg config.BaseConfig, m map[string]any) (Config, error)

func (*Config) Compile

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

type ConfigCompiled

type ConfigCompiled struct {
	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)

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. TODO1 make sure this enabled only 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

Source Files

httpcache.go

Version
v0.127.0
Published
Jun 5, 2024
Platform
windows/amd64
Imports
6 packages
Last checked
6 minutes ago

Tools for package owners.