Best way to fetch content via API without hitting cache?

I’m using Github notifications to trigger a build of a site but I am running into issues with caching when querying for content.

Sometimes when commits are made too soon behind eachother, fetching from raw.githubusercontent.com results in the second call hitting a cached version of the file.

What is the recommended way to prevent this from happening? I was hoping that using the API would providde a way to prevent this, but the API links to raw.githubusercontent.com for content and it still happens. I don’t want to actually do a git checkout of the files if possible.

If you’re referring to this endpoint, have you tried specifying the exact commit SHA that you want as the ref parameter? If you’re letting it default to the repository’s default branch, then yes, you may get cached information. Additionally, using the git data endpoint requesting the specific blob you want should give you the information you’re looking for.

I hope that helps!

2 Likes