Hi! Is there a way to cache (or rather store) between builds a resource from resources.GetRemote?
I started using resources.GetRemote two days ago, but build time is getting much longer than before, (due to the remote fetching, I guess). I tried processing the remote resources (they are images) to create processed images in /resources/_gen/images, but it doesn’t bypass remote fetching, just image processing.
So it’d be nice if Hugo could “cache” remote resource — just like it “caches” processed images storing them in /resources/_gen/images to bypass processing on following builds. It could create local resources in, for instance, /resources/_gen/remote and fetch from there in following builds.
Possible problem: a remote resource could change, turning the “cached” resource somewhat wrong. Perhaps all this “caching” could be enabled via a second argument to .GetRemote…
(I know at first it seems simpler to just download directly the remote resource and store it in Git. But I’m using .GetRemote to get YouTube/Vimeo thumbnails via oEmbed, which allows me — and content creators — to just paste a video link to get a nice thumbnail after build.)
Thank you again, @jmooring ! But perhaps I found a problem:
To ensure cache existence, I changed config to store it in a project folder:
[caches]
[caches.getjson]
dir = ':resourceDir/_gen'
maxAge = 2592000
[caches.getresource]
dir = ':resourceDir/_gen'
maxAge = 2592000
Then committed it, along with created files in those folders. But now, each build changes all files in getresource, which seems to mean Hugo is ignoring cache (getjson files don’t change). Is this correct?
This is the duration before a cache entry will be evicted, -1 means forever and 0 effectively turns that particular cache off. Uses Go’s time.Duration , so valid values are "10s" (10 seconds), "10m" (10 minutes) and "10h" (10 hours).