Support Forums

Build cache issue - Content from API (gohugo)

Hi, I am testing out goHugo + directus v9 API + netlify. : https://bimp01.netlify.app/

x-nf-request-id: 01F9E9PZ9KFYSAPSHX5NXQ4CEZ

Everything is working (also the build webhook), except the page content is not updated after a normal rebuild.
It only works if I manualy rebuild with “clear cache”.

How it works :
gohugo calls API to get content: {{ $data := getJSON “https://cms.bimp.be/items/hero_01” }}

and the data is passed in the html-page

<h1 class="title is-spaced">{{.hero_01_title}}</h1>
<p class="subtitle">{{.hero_01_subtitle}}</p>

I also checked if the directus api endpoint gets a new ETAG, and thats not the problem.
Netlify is stll using the cached json… can I somehow force the rebuild with “no cache”?
The http headers “max-age=0,no-cache,no-store,must-revalidate” arent helping with that.

I updated the content hero_01_title and subtitle to “NEW --…”, see screenshot or endpoint. But only if I do a manual clear cache rebuilf, the new content will be update. https://bimp01.netlify.app/ still has the old content

Thank you.

Just thinking… Can I use the onPrebuild event to clear the cache?

Solved it by adding a random non existing argument at the end of every api call.
I know its not the best solution but it works :
{{ $data := getJSON “https://cms.bimp.be/items/hero_01?var=123456789” }}

1 Like

Hey there, @alainb :wave:

Thanks for coming back and sharing this solution with the Forums! It will definitely be beneficial for future members who encounter something similar :netliconfetti: