Can not stop from pages getting stale

Currently developing a very basic web app. The whole idea is that anyone that accesses the page through the URL, puts a text on a textbox, clicks OK and the message is displayed. This text is recorded on a MongoDB collection and pulled from there. I am using NextJS 14.2 with App directory and directly building from Git on Vercel. My current problem is that on each new build taken on Vercel, current value of the message is recorded, statically. When a new value is entered and recorded on the database (this was checked) webpage is not updated as it is statically generated on new commit.

I moved my page to use server components, added headers for no cache on all API code.

export const dynamic = 'force-dynamic';
export const revalidate = 0; 

x-vercel-cache value is MISS, set cache’s to 0 of max age. I believe there is still something I need to set on the Vercel side but I am out of options.

Deleting the deployment cache resets to current value. This problem does not exist in localhost as it gets rebuilt on each new change.

Deployment URL or Custom Domain: https://senandism.vercel.app/
Environment (local, preview, production): production
Project Framework: NextJS
Build Settings:
  Framework Preset: Next.js
  Build Command (if not default):
  Output Directory (if not default):
  Install Command (if not default):
Node/Runtime Version: 20.x
Package Manager: npm
Relevant Packages: mongodb

Hey @beneielohim. Can you share more about how your project pulls the data from MongoDB? If you can share your public repo or a minimal reproducible example, that will let us debug together using the same code.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.