Gatsby/Github cache issue when fetching remote sources


I seem to be having some issue with Gatsby on Netlify.

I have Travis build a new file and publish it to to a GitHub Pages branch. I’ve set up GitHub to then trigger a Netlify build which then builds my Gatsby site. The Gatsby site is set up to pull in some remote sources including this file on GitHub.

The problem seems to be that that the file fetched is the old one, not the latest version. I can’t tell where the issue with this is, if it’s with GitHub, Gatsby, or Netlify.

Has anyone here run into this issue before?


Hi @cbetta,

There are a couple of ways to trigger Netlify builds. One is using a build hook, which by default will always pull from HEAD (latest), another is using the webhooks we add to your GitHub repo automatically, and the third is through our GitHub app, which all sites created via our web app in the last few months use by default. Assuming that the build is triggered via our GitHub app or webhooks we automatically add to your repo, we’ll clone the commit that’s sent in the webhook from GitHub. If you are using a build hook then we’ll clone the latest on the branch you specify.

Without knowing more details (including which site this is happening on), it’s hard to say more than this. Please let us know if this helps you resolve the issue.


So it turns out this issue was mostly arising from the issue I described in Triggering Netlify from a specific GitHub branch

Basically, when I committed to GitHub it would simultaneously trigger a Travis job and a Netlify build. The Netlify build would make a call to the GigHub page and prime GitHub’s cache for that edge. Then, when the GitHub page got updated, another Netlify build would get triggered. This second build would be so soon after the first that it would hit the GitHub cache.

The solution has been to proxy the GitHub webhooks through a Netlify function and filter out the first builds, but I’m still researching what the best way would be to access a file’s content via the API without hitting GitHub’s cache.