Next.js revalidatePath works on local build but not in App Platform

I have some static pages in my Next.js application (app router) that gets data from a database using Prisma. The data on those static pages change very rarely so the best option would be to manually revalidate it on demand. The solution I want to use works as expected locally: I make a build, open a page in a browser, update the DB data, run the route to revalidate, refresh the page and see the updated data. But it doesn’t work for the hosted app (App Platform), using the same process.

app -> (pages) -> my-page -> page.tsx

export default async function MyPage() {
    const data = await getMyData();

    return ( the data

app -> (pages) -> actions.ts

export async function getMyData() {
    return await{ orderBy: { order: 'asc' } });

app -> api -> revalidate -> route.ts

import { NextRequest, NextResponse } from 'next/server'
import { revalidatePath, revalidateTag } from 'next/cache'

export const dynamic = "force-dynamic";

export async function GET(request: NextRequest) {
    const path = request.nextUrl.searchParams.get('path') ?? "/";
    return NextResponse.json({ revalidated: path, now: });

Example use of the revalidate route:

How to make on-demand revalidation not using the timing option? (export const revalidate). Why does it work locally but not on DO?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Have you found any solution to that? I have pretty much same problem as you do. Wanted to use sanity webhooks to revalidate my content in next app but it works only localy.

Digital Ocean’s APP platform applies an additional level of cahcing through Cloudlfare. In these cases, requests made to* will actually be cached by cloudflare, and they will never reach your nextJs server, so they will never get the new content (until the age of the cache reaches the max-age defined in the Cache-Control header, which I believe is 1 year.

DO says disabling this cache can be done by setting a Cache-control to no-cache in the responses of your server, but at the same time nextJS say this is not allowed

Not sure of a solution for this, other than don’t use NextJS + DO

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel