From 7297c1172754078511ac1c10ca0dfd4cab629506 Mon Sep 17 00:00:00 2001 From: Fabian Tamp Date: Tue, 4 Aug 2020 12:59:52 +0200 Subject: [PATCH] Add note about caching for Hugo Pipes. As per discussion in [Is the new js.Build functionality cached?](https://discourse.gohugo.io/t/is-the-new-js-build-functionality-cached/27276) --- content/en/hugo-pipes/introduction.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/content/en/hugo-pipes/introduction.md b/content/en/hugo-pipes/introduction.md index 439ff6c67..bd5bfdc4c 100755 --- a/content/en/hugo-pipes/introduction.md +++ b/content/en/hugo-pipes/introduction.md @@ -50,3 +50,15 @@ The example above can therefore also be written as follows: {{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }} ``` + +### Caching + +Hugo Pipes invocations are cached based on the entire _pipe chain_. + +An example of a pipe chain is: + +```go-html-template +{{ $mainJs := resources.Get "js/main.js" | js.Build "main.js" | minify | fingerprint }} +``` + +The pipe chain is only invoked the first time it is encountered in a site build, and results are otherwise loaded from cache. As such, Hugo Pipes can be used in templates which are executed thousands or millions of times without negatively impacting the build performance.