Current versus Expected behavior
We are facing an issue where our Astro project, which is managed with MongoDB, does not use the latest MongoDB data after a redeploy. Specifically, when we make updates to MongoDB via Payload CMS, the new build process is triggered successfully using a vercel build trigger hook, but the deployment still uses outdated MongoDB data instead of the latest changes.
Expected behavior: The redeploy process should use the most recent MongoDB data during the build and deployment process.
Current behavior: The deployment uses cached or outdated MongoDB data, even though the build completes successfully.
Code, configuration, and steps that reproduce this issue
Our project is built with Astro and uses MongoDB for database management.
Payload CMS is integrated to manage and update the MongoDB data.
We have set up a hook in Payload CMS to trigger the build process whenever a database update is made.
The build completes successfully, but when deployed, the application does not reflect the updated MongoDB data. Instead, it shows the previous data.
Steps to reproduce:
Update data in Payload CMS.
Trigger a build process using the Payload CMS hook.
Redeploy the Astro project.
Observe that the deployed version does not reflect the updated MongoDB data.
Project information (URL, framework, environment, project settings)
Project Behavior: Static build with hooks triggering builds when MongoDB data is updated.
CMS Integration: Payload CMS to update MongoDB content.
We believe this issue may be related to caching during the build process or how static builds are generated in Astro. How can we ensure the deployment reflects the most recent MongoDB data?
Thanks it’s a nice place,
I don’t get any errors, builds finish successfully but the information on the website that is connected to my mongodb doesn’t get updated. When I try the same thing on local it builds as it’s expected, it fetches the latest information from my mongodb server and builds.
But on vercel, it deploys file changes like colors, layout etc without any problem but doesn’t fetch the latest information from the mongodb. I tried to flush the cache but it didn’t work. I tried to change the output from static to server and it didn’t worked too. I found some information about the same problem on vercel you can check on here next.js - NextJS application uploaded on Vercel not fetching updated record - Stack Overflow
Build cache management (using environment variables and clean scripts)
ISR (not applicable with our Astro setup)
The core issue seems to be that Vercel is somehow bypassing all our cache-busting attempts and still using prebuilt artifacts, even though the logs indicate the build cache is being skipped.
Would you have any insights on why Vercel might still use prebuilt artifacts despite all these measures? Is there perhaps a deeper level of caching we’re missing?