This project is designed to test various caching mechanisms in Next.js, utilizing both fetch
and axios
for API requests. The primary focus is to observe and understand how different caching strategies affect data fetching in a Next.js application.
Run any mock API server you prefer, for example: mockoon.
Configure your API endpoint in the .env file under TEST_API.
Example .env file:
TEST_API=http://127.0.0.1:4000/foobar
After the mock API is running, you can run:
npm run build
npm run start
to test the behavior.
The core functionality is implemented in the following locations:
app/action
: Tests api calls useserver action
.app/api/*
: Tests api calls usefetch
oraxios
.lib
: Reads the api URI from.env
.
https://nextjs.org/docs/app/building-your-application/caching
https://vercel.com/blog/common-mistakes-with-the-next-js-app-router-and-how-to-fix-them#static-or-dynamic-route-handlers
https://nextjs.org/docs/app/building-your-application/routing/route-handlers#caching