How does vercel run my code? Is my cache code working as intended?
You can use something for a long time yet not know what you're working with. I just came to a realization that something I am doing may not be correct:
This is one of my routers. It fetches data from an external source. The goal is to cache this data so I don't have to fetch it each time my clients send a request. But I am starting to understand that serverless stuff doesn't work that way...
I am using T3 and hosting on vercel.
Does this code make any sense? Or should I use something like redis for this?
Solution:Jump to solution
I was caching the fetch data in the api route so that clients can request that data from a third party from my api. This should not be done. I used getStaticProps with revalidate to put the data into the page which means no additional request is needed.
```typescript
export async function getStaticProps() {
const objects = await getObjects();
...
1 Reply
Solution
I was caching the fetch data in the api route so that clients can request that data from a third party from my api. This should not be done. I used getStaticProps with revalidate to put the data into the page which means no additional request is needed.
This solves the issue and even improves the general logic.