Can you provide details as to what cache is cleared when using the ‘Clear Cache and redeploy site’? What are the differences between a build that is triggered from a commit to the repository vs a build hook or the ‘Retry Deploy’ button?
Front end is Nuxt js 2.x with target set to ‘static’ (SSG). We are generating some custom routes by calling a Drupal backend API via Axios in a custom module. This generation setup happens at build time using Nuxt’s ‘buildModules’ configuration, and is hooking into the Vue router with the ‘extendRoutes’ hook to inject the custom paths. We have disabled the generater’s crawler as we are explicitly defining all of the routes for the site (generate.crawler = false).
Site name: bcrf.netlify.app
When new content (blog posts, products, etc) is created OR when existing content’s path is changed in the API, the new routes are not represented if the build is triggered via Build Hooks or the ‘Retry Deploy’ button in the Netlify Admin UI. The old routes (if changed) are present and appear to be served from cache while the new or changed routes return a 404 / Not Found. If a build is triggered from a commit to the Github repository or when selecting the ‘Clear Cache and redeploy site’ option in the Netlify UI, the new and changed routes work as expected. Content editors must be able to publish new content with new and changed routes via the build hooks triggered from the API without a commit to the repo or access to the Netlify UI.
We have tried
- Adding route generation in ‘modules’ rather than ‘buildModules’.
- Changing the sequence that the Nuxt modules are running (having route generation run first, etc).
- Removing the ‘.nuxt’ build directory (where the Vue router is eventually compiled) from Nuxt’s ‘generate.cache.ignore’ list.
- Clearing cache via appending “&& rm -rf …/cache” to build command as mentioned here: How to clear cache on branch deploy? - #2 by laura
- Subsequent builds from Build Hooks succeeded without error, but did not have new / changed routes. Subsequent builds triggered from the ‘Clear Cache and redeploy site’ Netlify UI failed due to missing directories. Committing a change to the repository seemed to fix the build cache and get things back to normal.
- Downloaded site files
- New route directories do not exist
- Only old routes exist. Altered routes do not.