Persistent Caching Issues on Next.js Firebase App Hosting - Old Version Still Live After Deploy

I’m hoping to get some community insight into a persistent caching issue I’m facing with a Next.js app on Firebase App Hosting (not the classic Firebase Hosting).

The Problem: After I publish a new version of my app through Firebase Studio, the live URL continues to serve an old, cached version. This happens even after waiting, doing hard refreshes (Ctrl+Shift+R), and clearing browser data. The changes are visible in the preview environment, but the live site is stuck on an old deployment.

What I’ve Tried So Far:

I’ve been working with gemini to troubleshoot this, and here’s a complete timeline of our attempts:

  1. Firebase Support’s PURGE Command: Support suggested running curl -X PURGE your-site-url. However, this command fails for both my default App Hosting URL and my custom domain, returning an “Internal Server Error” (HTTP 500) instead of a success message.
  2. Verifying Build Process: I discovered and fixed an issue where my package.json was missing a "build:prod" script, and apphosting.yaml wasn’t explicitly calling it. This has been corrected, and the app now builds correctly on deployment, but the caching issue persists on subsequent updates.
  3. next.config.js Headers: I added the standard Next.js header configuration to add long-lived Cache-Control headers to static assets (/public, max-age=31600000). This did not solve the issue.
  4. apphosting.yaml Headers: I then tried setting aggressive cache-control headers directly in apphosting.yaml for all files (source: /.*) to be no-cache, no-store, must-revalidate. This also did not solve the problem.

It seems like there’s an aggressive cache layer on App Hosting that is ignoring all my configuration attempts. Since the PURGE command is also failing, I’m out of ideas.

Has anyone else successfully solved this specific caching problem with Firebase App Hosting? Is there a known issue or a different configuration I should be using?

Any help or advice would be greatly appreciated!

I haven’t nearly solved the problem but I end up facing it frequently and end up abandoning the app I’m building, so would love any solution. It would be especially good if the Firebase team could create tutorial videos and step by step guide on what to do when this is encountered.

But you put it in words that I haven’t really been able to. I know something needs to be purged … I just don’t know what that is. But it isn’t really anything at the app code level. It is definitely internal to the VM build. I’m too afraid to start deleting things in the underlying system because I don’t know what is what; but clearly something is taking up too much space somewhere that I know can be gotten rid of.

Happy to provide Firebase with an example app if they need one.