# Cache Problem with Next.js on Vercel

**URL:** <https://community.prismic.io/t/cache-problem-with-next-js-on-vercel/15943>\
**Category:** Developing with Prismic\
**Tags:** nextjs\
**Created:** [May 17, 2024, 10:45am UTC](https://community.prismic.io/t/cache-problem-with-next-js-on-vercel/15943 "2024-05-17T10:45:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marvin.bernd](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@marvin.bernd](https://community.prismic.io/u/marvin.bernd)\
**Post date:** [May 17, 2024, 10:45am UTC](https://community.prismic.io/t/cache-problem-with-next-js-on-vercel/15943/1 "2024-05-17T10:45:47Z")

</div>

I have a caching problem with fetching the latest data from Prismic. I'm using Next.js App Router.

When running next build locally it doesn't fetch the new data from the Prismic Slices. My solution was to run "rm -rf .next/cache/fetch-cache && next build" as the build scripts. This works locally. But when running this script in production on Vercel I still got the old data fro Prismic.

Is anyone running into the same problem on Vercel?

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [May 17, 2024, 10:49am UTC](https://community.prismic.io/t/cache-problem-with-next-js-on-vercel/15943/2 "2024-05-17T10:49:11Z")

</div>

Hey @marvin.bernd,

What version of Next.js are you using? We had some caching problems last year around Next 13. You could look through this thread to see if there are any helpful workarounds:

> [@Caching issue with Next.js App Router - Vercel Deployment](https://community.prismic.io/t/caching-issue-with-next-js-app-router-vercel-deployment/13834):
>
> Dear Prismic team I set up a new Next.js App Router project using your setup command npx @slicemachine/init@latest and walking trough your step by step setup guide. In previous versions, I never had issues deploying the site to Vercel and setting up Prismic Webhooks to trigger redeploys. With this new project it seems like there are some caching issues with Vercel: If I push a new commit to Github or if I edit content on Prismic, it triggers a new deploy correctly. Unfortunately those deplo…

Sam

---

<div class="post-metadata">

**Author:** ![marvin.bernd](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@marvin.bernd](https://community.prismic.io/u/marvin.bernd)\
**Post date:** [May 17, 2024, 11:00am UTC](https://community.prismic.io/t/cache-problem-with-next-js-on-vercel/15943/3 "2024-05-17T11:00:06Z")

</div>

Hey @samlittlefair, thank you for your quick response!

I'm using Next 14.2.3. I already tried some solutions from this thread. And running "rm -rf .next/cache/fetch-cache" seems working locally. So I think it is more a Vercel problem. The only solution on Vercel was to click on the Button "Purge Everything" in the Data Cache Section of the Project Settings.

I actually have another Prismic and Next Project running on Vercel. And here it seems everything fine, even without clearing the cache folder. The only difference is that the other project uses mainly Server Components and this project (with the caching problem) is using mainly Client Components.

---

<div class="post-metadata">

**Author:** ![marvin.bernd](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@marvin.bernd](https://community.prismic.io/u/marvin.bernd)\
**Post date:** [June 3, 2024, 8:35am UTC](https://community.prismic.io/t/cache-problem-with-next-js-on-vercel/15943/6 "2024-06-03T08:35:08Z")

</div>

I got it working by changing

```auto
export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
  const client = prismic.createClient(repositoryName, {
    routes,
    accessToken: process.env.PRISMIC_ACCESS_TOKEN,
    fetchOptions:
      process.env.NODE_ENV === 'production'
        ? { next: { tags: ['prismic'] }, cache: 'force-cache' }
        : { next: { revalidate: 0 } },
    ...config,
  })

```

to

```auto
        ? { next: { tags: ['prismic'], revalidate: 0 } }
        : { next: { revalidate: 5 } },

```
