Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.32 KB

README.md

File metadata and controls

40 lines (26 loc) · 1.32 KB

Next.js Cache Mechanism Testing

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.

image

Peek 2024-07-18 20-02

Setup

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.

Project Structure

The core functionality is implemented in the following locations:

  • app/action: Tests api calls use server action.
  • app/api/*: Tests api calls use fetch or axios.
  • lib: Reads the api URI from .env.

Nextjs Doc Ref

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