Caching issues with hugo server

I’m having major caching issues with hugo server, and the CSS not being rebuilt.

I’m currently using this command, which, when run again correctly displays the latest CSS. But only after explictily being run:

hugo server --disableFastRender --environment=dev --bind "0.0.0.0"

And I get this output:

                   |  EN   
+------------------+------+
  Pages            | 1038  
  Paginator pages  |   17  
  Non-page files   |  943  
  Static files     |   44  
  Processed images |    0  
  Aliases          |   69  
  Sitemaps         |    1  
  Cleaned          |    0  

Total in 643 ms
Watching for changes in /myPATH/{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in /myPATH/config.toml
Environment: "dev"
Serving pages from memory
Web Server is available at //localhost:1313/ (bind address 0.0.0.0)
Press Ctrl+C to stop

Hard refreshes don’t help, I check the public folder and the CSS is not being written with the latest Sass.

I am using this Hugo Pipes setup for my Sass:

{{ if .Site.IsServer }}
{{ $cssOpts := (dict "targetPath" "css/bradbice.css" "enableSourceMap" true ) }}
{{ $styles := resources.Get "scss/bradbice.scss" | toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" media="screen, print">
{{ else }}
{{ $cssOpts := (dict "targetPath" "css/bradbice.css" ) }}
{{ $styles := resources.Get "scss/bradbice.scss" | toCSS $cssOpts | resources.Fingerprint "sha256" }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}" media="screen, print">
{{ end }}

Any ideas on what else I can check or try to have accurate cache refreshing (or disabled cache) with livereload?

I have not looked closely at your output, but I improved some of this in 0.57. What Hugo version are you running?

hugo version
Hugo Static Site Generator v0.57.0/extended darwin/amd64 BuildDate: unknown

I’ve had sporadic problems with LiveReload in Hugo 56.0 and above. Until a few days ago, I thought I had solved the problem by launching hugo server like this:

hugo -v server --path-warnings --ignoreCache --disableFastRender --renderToDisk --cleanDestinationDir

I thought "Aha, the trick (for my setup) is --renderToDisk" but alas, LiveReload quit working again and I’ve reverted to Hugo 55.6. I want to use the latest Hugo because I write about Hugo[*] and want to make sure what I write is correct.

I think this is related to this issue: ‘watch’ not working in vim on MacOS (0.56.*) #6139

[*] My Hugo-related writing is listed at https://www.ii.com/tag/gohugo/

1 Like

Any ideas on this? Development on macOS 10.14.6 is really bad with all of these caching issues.

I’m having to restart the server or run a separate hugo command in a separate terminal tab to have it correctly render.

To be clear I’m not saying this is a Hugo issue, but I’m looking for suggestions on what I can try to fix this.

For me, this seems to be fixed in v0.58.1/extended. I hope it is for you too!

1 Like

This is definitely not fixed for me, currently using v0.65.1/extended darwin/amd64.

I have to Ctrl/Cmd+C to stop the server and restart it every time I make a CSS change for it to show up in the browser. HTML markup changes do appear right away.

AutoReload also does not work with just hugo server.

One question: do you have dev tools open in your browser? (can I assume Chrome?). Chrome has an option to ignore the browser cache when dev tools are open.

I use Safari personally, but the browser has not mattered in this instance. The CSS is even fingerprinted, so browser cache should not be a problem.

I have the same issue, it was fine for a long time, then it sometimes it doesnt refresh, but then it worked sometimes as well, then suddenly stopped working altogether. Version 0.125. hugo server command.

On Windows, Firefox Developer Edition.

I think it’s a cache issue because if I leave it long enough and then do something to the CSS (I’m using PostCSS / TailwindCSS), it’ll reload the browser with the new style automatically, but then if I keep making changes, the CSS doesn’t get processed, no output. Console does show changes detected on the CSS file I changed, the public/css file doesnt change. The fingerprint doesn’t change either.

No issues with hugo or if I delete the public folder and rerun hugo server newest changes will be in, but any futher change I make to the CSS won’t be writtten to public.

These does nothing for this situation:
hugo server --ignoreCache

! set cacheDir in hugo.toml to a directory in my project to see what’s happening with the cache. Directory remains empty.

Edit: HTML doesn’t work either, changes are detected, but nothing is generated. No error reported.

Commenting on a 4-year-old topic probably isn’t going to get the attention that you need. I suggest you create a new topic.

Related: Support - TailwindCSS - HTML Template change not triggering CSS/PostCSS rebuild

The problem revolves around the fact that postcss does not get invoked by Hugo on “partial” rebuilds.

The hugo builder will handle different scenarios accordingly, in an attempt to prevent unnecessary rebuilds.

Full Rebuilds:
On Config file Change
On FSNotify events > 50
etc…

See: hugo/commands/hugobuilder.go at 1a53a8c2f5af4c1700ca98133db49a1126fd74ef · gohugoio/hugo · GitHub

I still do not understand how this seemingly affects only a minority of the users, indeed strange.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.