Cache retention versus force flag in Hugo resources.GetRemote retries
0 reputation · 24 Feb 2022, 08:02 UTC
Hugo's resources.GetRemote caches fetched content in the cache directory so subsequent calls reuse the cached file and avoid duplicate writes. When a transient failure occurs, Hugo retries the request up to three times internally, but the retry count is not configurable via the command line.
The Force flag available on resources.GetRemote bypasses the cache and forces a fresh download; using it on a retry overwrites the cached file rather than creating a new output, which prevents duplicate public files but may negate caching benefits. Running concurrent Hugo builds without isolated cache directories can introduce race conditions that might lead to duplicate writes.
Uncertainty remains about whether a retry that succeeds after cache use still results in a single file in the public directory, and whether the Force flag guarantees no duplicate output when retries happen in parallel environments.
- Under what conditions does a retry of
resources.GetRemotewithForceset tofalseproduce a second copy of the resource in the published output? - Does setting
Forcetotrueon a retry always overwrite the cached file without creating a duplicate public file, and how does cache directory isolation affect this in concurrent Hugo builds? - What is the effective file count in the public directory when a resource fetch fails entirely on the first attempt and succeeds on retry?