I included the image cache in source control to improve build performance on CI/CD workflow. It did.
But now when I run the site or build locally, many image files appear as “changed” although I did not change anything related to them (source images, processing options,…).
This makes it difficult to work with source control. I just change 1 one file, but I have to include dozens of images generated by hugo that I did not intend to change.
I know very little about your setup to give you details, but if you’re doing image processing in Hugo and change the original – all of the images that comes from that original will be generated with new filenames.
I have found that the best setup (for me anyhow) is to have
[caches]
[caches.images]
dir = ':cacheDir/:project'
maxAge = "800h" # or some high value
The above works right out of the box with Netlify (the cache gets restored on next build), but may not work that great with other CIs (or you would need some additional setup).
[caches]
[caches.images]
dir = ':resourceDir/:project'
maxAge = "-1" # or some high value
changing it to maxAge = “800h” did the trick. Now git is not flagging as ‘changed’ image files created by hugo (and which source have not been changed).
I thought “-1” meant forever.