prismicio / prismic-next

Helpers to integrate Prismic into Next.js apps
https://prismic.io/docs/technologies/nextjs
Apache License 2.0
57 stars 7 forks source link

feat: add experimental `prismic-next` CLI to clear Next.js fetch cache for Prismic requests #64

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR adds a prismic-next CLI to @prismicio/next to be used with Next.js 13 and App Router. Projects with @prismicio/next will automatically have the prismic-next CLI available.

The CLI contains one command: clear-cache. The command clears Next.js' fetch cache of any /api/v2 requests, which effectively allows a site refetch fresh content from Prismic.

Warning: The command is experiemental and unstable. It is provided as a temporary convenience until a more conventional cache cleaing solution is developed.

prismic-next clear-cache should be run before every next dev and next build command:

// package.json

{
  "scripts": {
    "dev": "prismic-next clear-cache && next dev",
    "build": "prismic-next clear-cache && next build"
  }
}

Checklist:

🐯

angeloashmore commented 1 year ago

This is being closed in favor or a simpler solution: cache bust /api/v2 requests at the @prismicio/client level.

See https://github.com/prismicio/prismic-client/pull/285 for more details.

angeloashmore commented 1 year ago

https://github.com/prismicio/prismic-client/pull/285 did not work out as initially expected.

This PR will be reopened in a new PR and considered for a possible official API.