Skip to content

'use cache' directive not working on Vercel production #82477

@bozzhik

Description

@bozzhik

Link to the code that reproduces this issue

https://github.com/mbozhik/apt/tree/cache

To Reproduce

  1. Clone the reproduction repository: https://github.com/mbozhik/apt (cache branch)

  2. Install dependencies and start the application in development mode:

pnpm install
pnpm dev
  1. Trigger the fetchSheetData function by navigating to the relevant route or making an API request (e.g. open /some-page that calls the function).

  2. Observe caching behavior:

  • First request takes ~12s (live fetch from API)
  • Subsequent requests return in ~500ms, confirmed via console logs starting with Cache
  1. Deploy the same code to Vercel with identical configuration.
  • Perform the same requests in production.
  • Observe that every request takes ~12s, with no Cache logs and no caching.

Current vs. Expected behavior

When following the reproduction steps, the application correctly caches requests in development mode. After the first API call (~12s), subsequent requests are returned in under 1 second and visibly marked with Cache logs — confirming that caching is working as expected.

Image

However, when deployed to Vercel in production, caching fails entirely. Every request triggers a full API call (~12s), with no sign of caching behavior:

  • No Cache logs
  • Identical repeated requests show no speedup
  • Caching directives ('use cache', cacheTag, cacheLife) are correctly placed but seemingly ignored
Image Image

Expected behavior:

Vercel production should match development caching — cached responses returned in <1s with logs confirming cache hits.

The discrepancy severely impacts UX, making production performance 10–15x slower than expected for identical requests.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 16

Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.10.0

Relevant Packages:
  next: 15.4.2-canary.33
  eslint-config-next: N/A
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.8.3

Next.js Config:
  output: N/A

Deployment:
  Platform: Vercel (Production)

Which area(s) are affected? (Select all that apply)

Use Cache

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

  • Reordered cache directives (cacheTag and cacheLife) — no effect.
  • Switched from axios to native fetch.
  • Removed all console.log calls inside cached functions.
  • Verified next.config.ts experimental settings (useCache, cacheComponents) and deployment configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions