NEXTJS_NO_TURBO_CACHE

Prevent Turborepo from caching the Next.js .next/cache folder to prevent an oversized cache.
Table of Contents

Conformance is available on Enterprise plans

This rule prevents the .next/cache folder from being added to the Turborepo cache. This is important because including the .next/cache folder in the Turborepo cache can cause the cache to grow to an excessive size. Vercel also already includes this cache in the build container cache.

The following turbo.json config will be caught by this rule for Next.js apps:

turbo.json
{
  "extends": ["//"],
  "pipeline": {
    "build": {
      "outputs": [".next/**"]
    }
  }
}

To fix, add "!.next/cache/**" to the list of outputs for the task.

turbo.json
{
  "extends": ["//"],
  "pipeline": {
    "build": {
      "outputs": [".next/**", "!.next/cache/**"]
    }
  }
}
Last updated on July 23, 2024