NextJS/Vercel Caching with Github Access Tokens
Answered
.dric posted this in #help-forum
.dricOP
Hello,
So I believe I'm having an issue with Vercel caching:
I'm using the Github API, and storing user's installation id + generated access token within my database. When the user signs in, we fetch the user's tokens from the database.
When testing this in localhost/development, it works and after reading about caching, I learned that the cache in development mode is
After long thought and pain, I've come to a conclusion that this is a caching issue, but I might also be wrong, however I'm almost certain this is the case.
I was reading [this stack overflow post](https://stackoverflow.com/questions/76228269/setting-cache-control-header-in-nextjs-app-router) and one comment was to switch to another host such as Remix if you want more control over your caching.
What are you guys' thoughts on the whole matter? How do I solve this issue, or should I just switch hosts completely. To be honest, I might switch hosts in the future since scaling with Vercel is expensive.
Information that might be important:
I'm using the App Router, and am using version 14.2.23
So I believe I'm having an issue with Vercel caching:
I'm using the Github API, and storing user's installation id + generated access token within my database. When the user signs in, we fetch the user's tokens from the database.
When testing this in localhost/development, it works and after reading about caching, I learned that the cache in development mode is
no-store, must-revalidate
. In contrast, it's opposite in production so calls to API routes are cached, so I have to manually purge cache on the vercel website for my project every time the tokens expire before my token revalidation function works and I'm able to fetch data using the Github API. This is weird though, because I have a function that revalidates the tokens after they expire.After long thought and pain, I've come to a conclusion that this is a caching issue, but I might also be wrong, however I'm almost certain this is the case.
I was reading [this stack overflow post](https://stackoverflow.com/questions/76228269/setting-cache-control-header-in-nextjs-app-router) and one comment was to switch to another host such as Remix if you want more control over your caching.
What are you guys' thoughts on the whole matter? How do I solve this issue, or should I just switch hosts completely. To be honest, I might switch hosts in the future since scaling with Vercel is expensive.
Information that might be important:
I'm using the App Router, and am using version 14.2.23
Answered by Anay-208 | Ping in replies
And its not necessary for you to host on Vercel.
You can host on AWS, Cloudflare Pages, Netlify, and so on.
You can host on AWS, Cloudflare Pages, Netlify, and so on.
8 Replies
And its not necessary for you to host on Vercel.
You can host on AWS, Cloudflare Pages, Netlify, and so on.
You can host on AWS, Cloudflare Pages, Netlify, and so on.
Answer
@Anay-208 | Ping in replies Whats your Next.js version?
In v15, cache is disabled by default.
.dricOP
My previous version was 14.2.23.
I upgraded to v15 about 45minutes ago after reading that cache is disabled by default in v15, so I'm optimistic to see how that'll be in production.
About hosting: yes I know that's true. I've just been using Vercel since NextJS is native to the Vercel environment, however I will look into AWS.
I upgraded to v15 about 45minutes ago after reading that cache is disabled by default in v15, so I'm optimistic to see how that'll be in production.
About hosting: yes I know that's true. I've just been using Vercel since NextJS is native to the Vercel environment, however I will look into AWS.
The only problem I had with upgrading though, was package dependencies that didn't support React 19, so I had to do it by
--force
@.dric My previous version was 14.2.23.
I upgraded to v15 about 45minutes ago after reading that cache is disabled by default in v15, so I'm optimistic to see how that'll be in production.
About hosting: yes I know that's true. I've just been using Vercel since NextJS is native to the Vercel environment, however I will look into AWS.
You can use OpenNext to deploy to AWS