Netlify function usage with cache


We’re running a function on our careers page for getting updates to jobs. This function fetches from an API, and stores the data in a cache which expires every 15 minutes and then would fetch the latest data again on the next page view.

We’re trying to get an understanding of how this would impact our functions usage. The site gets a decent amount of traffic and the careers page gets around 100 page views per day.

One question we have is does a request to read the cache count as a function request and would it use one of our 125,000 monthly function requests? Same with the hours we have? Or does the cache just come straight from the server and wouldn’t use the Netlify functions at all until the cache expired?

In general, we’re just trying to figure out if this is going to cost us extra per month or not


Hiya @chrish,

Functions are accessed in the same way as any URL that proxies to another site: if you set a Cache-Control HTTP response header value, we’ll respect it. HOWEVER, that is handled per-CDN-node, and we have dozens of them, so if you really get steady traffic to that page at dozens of visits per 15 minutes, then you’ll have 24x4x(dozens) of function executions per day. Of course even that takes a very long time to add up to Functions Level 1 usage :slight_smile: Plus, in reality, you’ll probably not get such steady traffic that every node needs to look up a result every 15 minutes, but it’s still probably in that order of magnitude.

Perhaps you could instead come up with a workflow that rebuild your site every time there is an update, using an incoming webhook? - this would allow you to “push” an update (well a notification that there is an update), instead of polling. Then our CDN cache handles the details of only updating when needed, and you run 0 functions. You can presumably achieve the same workflow during build (poll data source, update data) that you could from the function.

If you make hundreds of updates to your jobs page every day, then that is suboptimal. But I suspect you don’t :slight_smile: