summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-11 10:34:08 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-13 09:18:17 +0200
commit2dbdf38a5411c554146ddd915a0aea3b2eaf4407 (patch)
tree333aaaac81aff606b1e6d39adc1663cec0fa8a32 /docs
parentf8c4e1690a462a2dcafa05aeaab65d1fad6df61e (diff)
resources: Add `key` to reources.GetRemote options map
If set, `key` will be used as the only cache key element for the resource. The default behaviour is to calculate the key based on the URL and all the options. This means that you can now do: ``` {{ $cacheKey := print $url (now.Format "2006-01-02") }} {{ $resource := resource.GetRemote $url (dict "key" $cacheKey) }} ``` Fixes #9755
Diffstat (limited to 'docs')
-rwxr-xr-xdocs/content/en/hugo-pipes/introduction.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/content/en/hugo-pipes/introduction.md b/docs/content/en/hugo-pipes/introduction.md
index 83d64d1d3..bbafe55b2 100755
--- a/docs/content/en/hugo-pipes/introduction.md
+++ b/docs/content/en/hugo-pipes/introduction.md
@@ -53,6 +53,19 @@ With `resources.GetRemote`, the first argument is a remote URL:
`resources.Get` and `resources.GetRemote` return `nil` if the resource is not found.
+### Caching
+
+By default, Hugo calculates a cache key based on the `URL` and the `options` (e.g. headers) given.
+
+
+{{< new-in "0.97.0" >}} You can override this by setting a `key` in the options map. This can be used to get more fine grained control over how often a remote resource is fetched, e.g.:
+
+
+```go-html-template
+{{ $cacheKey := print $url (now.Format "2006-01-02") }}
+{{ $resource := resource.GetRemote $url (dict "key" $cacheKey) }}
+```
+
### Error Handling
{{< new-in "0.91.0" >}}