I am using Next.js 16 with App Router and cacheComponents: true deployed on Vercel.
I have two cached server functions:
getMenu()→ uses"use cache"and caches correctly on both localhost and Vercel.getHoroscope(day, sign)→ also uses"use cache"withcacheLife("horoscope"), but on Vercel it executes on every request instead of returning cached data.
Expected behavior
The getHoroscope() function should be cached according to the configured cacheLife, and subsequent requests for the same day and sign should return the cached result.
Actual behavior
Local development: cache works as expected.
Vercel deployment: getHoroscope()executes on every request.
getMenu()caching works correctly on the same deployment.
Route
/horoscopes/[day]/[sign]
Example:
https://darshan24-frontend-next.vercel.app/horoscopes/daily/aries
Cache configuration
cacheComponents: true,
cacheLife: {
menus: {
stale: 2592000,
revalidate: 2592000,
expire: 2592000,
},
horoscope: {
stale: 86400,
revalidate: 3600,
expire: 604800,
},
}
Cached function
export async function getHoroscope(day: string, sign: string) {
"use cache";
cacheLife("horoscope");
const res = await fetch(
`${process.env.API_URL}wp-json/v1/horoscopes/get-data?day=${day}&rashi=${sign}`
);
return res.json();
}
Additional information
- The data comes from a WordPress REST API.
- The API returns deterministic data for the same
dayandsign. - No
cookies(),headers(), ordraftMode()are used in the cached function. - The menu cache works correctly in the same application, so caching is not completely broken.
- The issue only affects the horoscope data function on Vercel.
Has anyone experienced this with use cache on dynamic routes, or is there any known limitation or configuration required on Vercel?