# Issue with image cache in source control

**URL:** <https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634>\
**Category:** support\
**Tags:** images\
**Created:** [September 22, 2022, 1:17pm UTC](https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634 "2022-09-22T13:17:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgrins](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sgrins/32/10498_2.png) [@sgrins](https://discourse.gohugo.io/u/sgrins)\
**Post date:** [September 22, 2022, 1:17pm UTC](https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634/1 "2022-09-22T13:17:49Z")

</div>

Hi

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.

Maybe I’m missing some setting here?

---

<div class="post-metadata">

**Author:** ![bwintx](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bwintx/32/10450_2.png) [@bwintx](https://discourse.gohugo.io/u/bwintx)\
**Post date:** [September 22, 2022, 1:43pm UTC](https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634/2 "2022-09-22T13:43:22Z")

</div>

You might want to play with this config setting:

> **[Configure Hugo](https://gohugo.io/getting-started/configuration/#configure-file-caches)**
>
> How to configure your Hugo site.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [September 22, 2022, 2:53pm UTC](https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634/3 "2022-09-22T14:53:39Z")

</div>

> [@sgrins](#):
>
> 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

```toml
[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).

---

<div class="post-metadata">

**Author:** ![sgrins](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sgrins/32/10498_2.png) [@sgrins](https://discourse.gohugo.io/u/sgrins)\
**Post date:** [September 22, 2022, 4:00pm UTC](https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634/4 "2022-09-22T16:00:29Z")

</div>

Thanks for your suggestions.

I had

```auto
[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.

Just for the record, I’m using Gitlab’s CI

---

<div class="post-metadata">

**Author:** ![gaetawoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/gaetawoo/32/16789_2.png) [@gaetawoo](https://discourse.gohugo.io/u/gaetawoo)\
**Post date:** [September 22, 2022, 5:57pm UTC](https://discourse.gohugo.io/t/issue-with-image-cache-in-source-control/40634/5 "2022-09-22T17:57:48Z")

</div>

What does the `caches` bit output and where such that it is read by Netlify?
