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 Jun 5, 2024
1 parent 6da2196 commit 927c905
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
47 changes: 47 additions & 0 deletions content/en/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,52 @@ 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 relevant when using the [resources.GetRemote] function.

The caching in Hugo is layered:

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

Dynacache

Check warning on line 879 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 behavior (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.

File Cache
: See [file cache].

The default HTTP cache disables everything:

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

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

polling
: Enables polling _for_ a set of resources. Note that you can enable polling for resources even if HTTP 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 @@ -916,3 +962,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

16 changes: 16 additions & 0 deletions data/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,20 @@ chroma:
- zig
Name: Zig
config:
HTTPCache:
cache:
for:
excludes:
- '**'
includes: null
polls:
- disable: true
for:
excludes: null
includes:
- '**'
high: 0s
low: 0s
archeTypeDir: archetypes
assetDir: assets
author: {}
Expand Down Expand Up @@ -1721,6 +1735,8 @@ config_helpers:
_merge: none
frontmatter:
_merge: none
httpcache:
_merge: none
imaging:
_merge: none
languages:
Expand Down

0 comments on commit 927c905

Please sign in to comment.