Next.js Discord

Discord Forum

See which functions are being used in vercel?

Answered
Serengeti posted this in #help-forum
Open in Discord
Avatar
SerengetiOP
Is there a way on vercel to see which functions are being used. I have a high number of function invocations, a few thousand a day (with less than 100 visitors a day) so a bit confused why its so high so want to see which functions are being called.
Answered by Serengeti
@B33fb0n3 i have contacted them regarding the static pages having invocations, but having done more experiments it seems that server pages always generate invocations and its just the data that is cached. I have made them static by adding "force-static" to the dynamic option and seems to do what I expect there now.
View full answer

16 Replies

Avatar
yea, you can look at the logs on which functions/path will be executed. Even if you have only the last 30min, you can still see which are mostly used
Avatar
SerengetiOP
hey, yeah i think i found my most used. but it is odd. in the last 7 days my GA says ive had 251 page views. and yet in those path invocations it has 15k invocations, with the top path being around 2k invocations. Im not sure how I have such a big disparity here.

I'm using the app dir and all my pages are cached with ISR and very rarely is that cache revalidated, in fact in the last 7 days it was only invalidated twice (both times on the same day).
Avatar
Well.. you GA Tag may not collect bot activity, but vercel does. So GA filters everything out, to show you the data of real persons and vercel shows you everything
Avatar
SerengetiOP
Yeah that is something I had considered but I don't know why its so high on invocations when its supposed to not count cached requests?

I'm using revalidatePath when pages need updated, so in the last 7 days the pages cache should only have been cleared twice, and yet its stil showing thousands on invocations. unless im missing something about the cache/invocation and need to update my code
Avatar
SerengetiOP
Looking at a request to my home page I can see it has a cache control of private, no-cache, no-store, max-age=0, must-revalidate and a x-vercel-cache: is MISS. I thought vercel cached everything by default? Do I need to specifcy cache control headers for each page specifically in the next.config.js?
Avatar
How do you cache your pages? What’s the code for it?
Avatar
SerengetiOP
I'm not using anything really, next just caches automatically doesnt it? I have my database fetches in my page (server) and i assume next just caches it automatically.

I think some issue I can see is that on some pages I use searchParams so I can see why that is not cached as its a dynamic function, but my home page shouldn't be affected by that and I still see thousands of invocations on that page
Avatar
when your page is fully static (check the symbol when building) it will also be statically served yea. However when it's dynamic, everything stays dynamic. There is no cache by default for fetch in next15. In next14 it's cached by default, but I don't think you using fetch for your database
Avatar
SerengetiOP
@B33fb0n3 im using next14 yeah, and yeah no fetch just database calls. I assumed with the revalidatePath stuff etc, that stuff was automatically cached until you revalidate (im pretty sure thats what the docs say)

Weirdly though, I do have some pages which are completely static (○ /terms-and-conditions this is in my build logs) and yet that page is still getting thousands of invocations according to my usage Top Paths. That shouldn't be the case should it?
Avatar
hm yea, iirc even if these pages are already generated there are still function invocations to build the page together 🤔
Avatar
SerengetiOP
@B33fb0n3 even the static ones? seems a bit odd, in vercels optimisation thing they say static pages dont generate invocations.
Avatar
can you link me the specific docs so I can take a deeper look into this?
Avatar
hm yea you are right. I guess it's the best to contact vercel itself thought this:
Avatar
SerengetiOP
@B33fb0n3 i have contacted them regarding the static pages having invocations, but having done more experiments it seems that server pages always generate invocations and its just the data that is cached. I have made them static by adding "force-static" to the dynamic option and seems to do what I expect there now.
Answer
Avatar
ah thanks for letting me know 👍