# Cache Problems

**URL:** <https://discourse.gohugo.io/t/cache-problems/27480>\
**Category:** support\
**Created:** [August 10, 2020, 1:29pm UTC](https://discourse.gohugo.io/t/cache-problems/27480 "2020-08-10T13:29:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![andybrite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andybrite/32/12071_2.png) [@andybrite](https://discourse.gohugo.io/u/andybrite)\
**Post date:** [August 10, 2020, 1:29pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/1 "2020-08-10T13:29:29Z")

</div>

Hey,

i’ve again massive Problems with my files in the static folder.

each css, js file will not be reload (for example - visitors without “private” browser mode)

my htaccess file has the following entries:

```
    # DISABLE CACHING
<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>
<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
    </IfModule>
</FilesMatch>

```

i’ve nothing in my meta tags.

is there an other solution, do i miss anything ?

structure for my css/js files is:

-Site  
– theme  
— mytheme  
---- static  
----- css  
----- js  
----- frameworkCss  
----- fonts

Is it possible to create (if generate the site) an additional hash at the end of the files? like an cms system who caches all these things? (example: css/mystyle6ztetgdu2kds7832.css)

Thanks for your support  
Andy

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [August 10, 2020, 2:18pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/2 "2020-08-10T14:18:38Z")

</div>

The way I understand you, you want to reload the CSS file every time? Did you try removing all the stuff you posted of your .htaccess? If it’s just about the css files then remove the `css|` part of your code.

---

<div class="post-metadata">

**Author:** ![nfriedli](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nfriedli/32/26027_2.png) [@nfriedli](https://discourse.gohugo.io/u/nfriedli)\
**Post date:** [August 10, 2020, 3:16pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/3 "2020-08-10T15:16:23Z")

</div>

> [@andybrite](#):
>
> Is it possible to create (if generate the site) an additional hash at the end of the files? like an cms system who caches all these things? (example: css/mystyle6ztetgdu2kds7832.css)

Just have a look here: [Fingerprint | Hugo](https://gohugo.io/hugo-pipes/fingerprint/)

With your CSS in `assets/css/`:

```
{{ $styles := resources.Get "css/main.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}" media="screen">

```

or just:

```
{{ $styles := resources.Get "css/main.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.Permalink }}" media="screen">

```

---

<div class="post-metadata">

**Author:** ![andybrite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andybrite/32/12071_2.png) [@andybrite](https://discourse.gohugo.io/u/andybrite)\
**Post date:** [August 10, 2020, 3:37pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/4 "2020-08-10T15:37:48Z")

</div>

Yes, i’ll edit the htaccess. Thank you!

---

<div class="post-metadata">

**Author:** ![andybrite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andybrite/32/12071_2.png) [@andybrite](https://discourse.gohugo.io/u/andybrite)\
**Post date:** [August 10, 2020, 3:41pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/5 "2020-08-10T15:41:04Z")

</div>

This sound verry good! My hope is that the server understands a change of the file. It’s crazy, but on some devices (without private mode, or manually cache cleaning, the css style stays does’nt change, same with jpg) is it better to put all “dynamic css” files to the assets folder?

---

<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:** [August 10, 2020, 4:13pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/6 "2020-08-10T16:13:58Z")

</div>

> [@andybrite](#):
>
> is it better to put all “dynamic css” files to the assets folder?

Yes. If you use the `fingerprint` function (see above), that will effectively handle the cache busting for you.

---

<div class="post-metadata">

**Author:** ![andybrite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andybrite/32/12071_2.png) [@andybrite](https://discourse.gohugo.io/u/andybrite)\
**Post date:** [August 10, 2020, 4:22pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/7 "2020-08-10T16:22:28Z")

</div>

It works! How often will hugo generate the cash new? I’ve edit the css file, but the hash is the same. Are they settings to change that? After each editing?

> Is this all in the cache part of the config file? Best Value for that eg. maxAge = -1 ?

Thanks a lot for all your help!!!  
Andreas

---

<div class="post-metadata">

**Author:** ![andybrite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andybrite/32/12071_2.png) [@andybrite](https://discourse.gohugo.io/u/andybrite)\
**Post date:** [August 10, 2020, 6:04pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/8 "2020-08-10T18:04:30Z")

</div>

One last question…

Is it possible to do that with “images”. put to the asset folder, create a hash etc.

I’m using hugo as a One Pager without “blog” elements and only a data sheet from json/toml to get fresh data…

Thanks  
Andy

---

<div class="post-metadata">

**Author:** ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)\
**Post date:** [August 10, 2020, 6:18pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/9 "2020-08-10T18:18:55Z")

</div>

I don’t see why it shouldn’t.

---

<div class="post-metadata">

**Author:** ![andybrite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andybrite/32/12071_2.png) [@andybrite](https://discourse.gohugo.io/u/andybrite)\
**Post date:** [August 10, 2020, 6:52pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/10 "2020-08-10T18:52:18Z")

</div>

Hi,  
if i edit an image and save this image with the same name etc. sometimes the webbrowser does‘nt register that. so some people have the same image like the last visit. (if they don‘t clear rhe cache of there browser).

Do i think here in a wrong way? Is this again more a problem of the headers? the cache control?

Thank you  
Andy

---

<div class="post-metadata">

**Author:** ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)\
**Post date:** [August 10, 2020, 7:05pm UTC](https://discourse.gohugo.io/t/cache-problems/27480/11 "2020-08-10T19:05:11Z")

</div>

Not sure if you’re overthinking or I’m not thinking enough.

The `fingerprint` can also be used in resources like images. Processed images will also be named like `image_hu3d03a01dcc18bc5be0e67db3d8d209a6_1055507_1200x600_fill_q75_box_smart1.jpg`.

AFAIK, there’s nothing more on Hugo side to prevent cache problems. ¯\_(ツ)\_/¯
