Is there a way to cache bust assets in page bundles? For example, one can assign post-related image files a very long browser TTL. Updating images in posts would naturally cause browsers to re-request the image from the server.
Not sure if I understand, it sounds like the cachebusters
options only work for JS and stylesheets?
content/
βββ posts/
βββ post-1/
βββ a.jpg
βββ index.md
layouts/_default/single.html
{{ with .Resources.Get "a.jpg" | fingerprint }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
You can optionally add an SRI hash at the same time:
{{ with .Resources.Get "a.jpg" | fingerprint }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
If you want to fingerprint images that are reference via markdown links, use an image render hook, perhaps starting with Hugoβs embedded image render hook as a model:
1 Like
Looks like fingerprinting canβt be automated but some manual setup would make it work. Thanks!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.