Hugo Pipes - Fingerprinting

Hey community

I would like to setup cache busting. I change CSS very often.
So I used pipes with fingerpriting. It work.
The name get the hash but the hash never change on rebuild with hugo & hugo server.
So my cache busting won’t work.

{{ $style := resources.Get "css/main.css" | minify | fingerprint }} 
<link rel="stylesheet" href="{{ $style.Permalink }}">

The hash should change when I update my css file?

You need to add the integrity attribute. See below replies

You don’t need that attribute for “cache busting”.

Yes.

Hello zwbetz

I don’t need integrity because it was stupid thing…
I edited only comments in CSS /* bla bla */

Result the hash never change

So I change CSS line and immediately the hash change !
I think the minify cause that.

Yes, that sounds logical.

(The HUGO community is the best ★★ thanks bep, zwbetz)

1 Like

@bep Nice. TIL when using fingerprint on an asset, its .Permalink includes a hash.

2 Likes

Yes, I can add that the SRI Integrity thing is a nice side effect of the fingerprinting (which is mainly motivated by cache busting): We can reuse the same hash (which can be somewhat expensive to calculate) for the Integrity string.

1 Like