Skip to content

Commit

Permalink
Document HTTP cache config
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed May 23, 2024
1 parent 8f939ed commit 73594df
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
48 changes: 48 additions & 0 deletions content/en/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,53 @@ If you want to know the current value of `cacheDir`, you can run `hugo config`,
[static-files]: /content-management/static-files/


## Configure HTTP cache

{{< new-in 0.127.0 >}}

Note that this configuration is currently only relevevant when using the [resources.GetRemote] function.

Check warning on line 857 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (relevevant)

Check warning on line 857 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (relevevant)

The caching in Hugo is layered:

```goat {.w-40}
.-----------.
| dynacache |
'-----+-----'
|
v
.----------.
| HTTP cache |
'-----+----'
|
v
.----------.
| file cache |
'-----+----'
```

Dynacache

Check warning on line 877 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (Dynacache)

Check warning on line 877 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (Dynacache)
: A in memory LRU cache that gets evicted on changes, [Cache Buster](#configure-cache-busters) matches and in low memory situations.

HTTP Cache
: Enables HTTP cache behaviour (RFC 9111) for remote resources. This works best for resources with properly set up HTTP cache headers. The HTTP cache uses the [file cache] to store and serve cached resources.

Check warning on line 881 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (behaviour)

Check warning on line 881 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (behaviour)

File Cache
: See [file cache].


The default HTTP cache configuration is:

{{< code-toggle config=HTTPCache />}}

caching
: Enabled RFC 9111 cache behaviour _for_ a configured set of resources. Stale resources will be refreshed from the [file cache] even if their configured TTL isn't reached.

Check warning on line 892 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (behaviour)

Check warning on line 892 in content/en/getting-started/configuration.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (behaviour)

polling
: Enables polling _for_ a set of resources. Note that you can enable polling for resources even if caching is disabled. This setting is only used when in watch mode (e.g. `hugo server`). When a change resource is detected, that change triggers a rebuild of pages using that resource.

[resources.GetRemote]: /functions/resources/getremote/
[file cache]: #configure-file-caches

## Configure segments

{{< new-in 0.124.0 >}}
Expand Down Expand Up @@ -914,3 +961,4 @@ Some use cases for this feature:
[kind]: /getting-started/glossary/#page-kind
[output format]: /getting-started/glossary/#output-format
[type]: /getting-started/glossary/#content-type

33 changes: 33 additions & 0 deletions data/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,36 @@ chroma:
- zig
Name: Zig
config:
HTTPCache:
caching:
for:
excludes:
- '**{.jpg,.jpeg,.png,.webp,.gif,.ttf}'
includes:
- '**'
polls:
- disable: true
for:
excludes: null
includes:
- '**{.jpg,.jpeg,.png,.webp,.gif,.ttf}'
high: 0s
low: 0s
- disable: false
for:
excludes: null
includes:
- https://*.git.luolix.top/**
- https://*.twitter.com/**
high: 30m0s
low: 10m0s
- disable: false
for:
excludes: null
includes:
- '**'
high: 30s
low: 1s
archeTypeDir: archetypes
assetDir: assets
author: {}
Expand All @@ -939,6 +969,7 @@ config:
cacheBusters:
- source: (postcss|tailwind)\.config\.js
target: (css|styles|scss|sass)
duplicateResourceFiles: false
noJSConfigInAssets: false
useResourceCacheWhen: fallback
buildDrafts: false
Expand Down Expand Up @@ -1721,6 +1752,8 @@ config_helpers:
_merge: none
frontmatter:
_merge: none
httpcache:
_merge: none
imaging:
_merge: none
languages:
Expand Down

0 comments on commit 73594df

Please sign in to comment.