#Vercel's Data cache not working

6 messages · Page 1 of 1 (latest)

hazy sentinel
#

I am using unstable_cache.

I am running into an issue where the caching doesn't work AT ALL once I deploy to Vercel.

Locally, the caching work perfectly, but on vercel it's missing the cache every single time.

I started out using unstable_cache initially but switched to nextjs-better-unstable-cache as the DX is poor for the current unstable_cache. The same issue occures using either unstable_cache directly or the wrapper library.

Local Logs:

Data Cache - Get All Dealers  HIT 0.0533s
Memoization - Get All Dealers  HIT 0.0601s

Data Cache - Get All Dealers  HIT 0.0164s
Memoization - Get All Dealers  HIT 0.0176s

Data Cache - Get All Dealers  HIT 0.0101s
Memoization - Get All Dealers  HIT 0.0158s

Data Cache - Get All Dealers  HIT 0.00245s
Memoization - Get All Dealers  HIT 0.00296s

Data Cache - Get All Dealers  HIT 0.00466s
Memoization - Get All Dealers  HIT 0.0100s

Vercel Logs (had a hard time just copying the console.logs):

Memoization Get All Dealers HIT 0.715s
Data Cache Get All Dealers MISS 0.715s on-demand revalidation
missing getAllDealers
Memoization Get All Dealers HIT 0.329s
Data Cache Get All Dealers MISS 0.329s on-demand revalidation
missing getAllDealers
Memoization - Get All Dealers HIT 0.246s
Data Cache Get All Dealers MISS 0.245s on-demand revalidation
missing getAllDealers
Memoization Get All Dealers HIT 0.628s
Data Cache Get All Dealers MISS 0.628s on-demand revalidation
missing getAllDealers
Memoization
-
Get All Dealers HIT 0.332s
Data Cache - Get All Dealers MISS 0.331s on-demand revalidation
missing getAllDealers
Memoization Get All Dealers HIT 0.741s
Data Cache Get All Dealers MISS 0.736s on-demand revalidation
missing getAllDealers
Memoization
-
Get All Dealers HIT 0.336s
Data Cache
-
Get All Dealers MISS 0.336s on-demand revalidation
frank patrolBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

hazy sentinel
#

Function in question

import { db } from "../db"
import { memoize } from "nextjs-better-unstable-cache"

export const getAllDealers = memoize(
  async () => {
    console.log("missing getAllDealers")
    const data = await db.dealers.findMany({
      where: { active: 1, consumer_site_enabled: 1 },
      include: {
        _count: {
          select: {
            dealer_reviews: {
              where: {
                rating: 5,
              },
            },
          },
        },
      },
    })
    return data
  },
  {
    additionalCacheKey: ["get-all-dealers"],
    persist: true,
    duration: SiteConfig.cache.revalidateTime,
    revalidateTags: ["get-all-dealers"],
    log: ["dedupe", "datacache", "verbose"],
    logid: "Get All Dealers",
  }
)

My revalidateTime/duration: revalidateTime: 60 * 60 * 24 * 30 * 1000, (30d)

#

My package versions:

"next": "^14.0.2",
"nextjs-better-unstable-cache": "^1.0.0",

#

Ok I ugraded to 14.04, and it looks like it's resolved now: