Functions resources
Refer to the following resources to learn more about Netlify Functions:
Or start building with one of our platform starters.
Netlify Platform Primitives are framework-agnostic runtime features of our platform. They are used in our framework adapters to offer consistent functionality and freedom regardless of your chosen framework.
These primitives can also be used directly to transform stale pages and static pages into dynamic experiences that best suit your architectural strategy and needs:
With Netlify Functions, your serverless functions are version-controlled, built, and deployed along with the rest of your Netlify site, and we will automatically handle service discovery through our built-in API gateway. This eliminates overhead and brings the power of Deploy Previews and rollbacks to your functions. During a build, we automatically generate functions for web frameworks that support server-side rendering and/or API endpoints. This is done though a build plugin or adapter for that framework.
If you are using a framework that does not support server-side rendering, you can still add dynamic behavior by creating functions directly.
Functions resources
Refer to the following resources to learn more about Netlify Functions:
Or start building with one of our platform starters.
Edge Functions connect the Netlify platform and workflow with an open runtime standard at the network edge. This enables you to build fast, personalized web experiences with an ecosystem of development tools.
Using TypeScript and JavaScript, you can modify network requests to localize content, serve relevant ads, authenticate users, personalize content, redirect visitors, and much more. Edge Functions also support a new generation of edge-first web frameworks allowing your entire app to run at the edge, dramatically increasing performance in many cases.
All this dynamic processing happens in a secure runtime based on Deno directly from the worldwide network edge location closest to each user for fast response times. Plus, you have the option to cache edge function responses for even faster response times. With Netlify, your edge functions are version-controlled, built, and deployed along with the rest of your Netlify site. This eliminates overhead and brings the power of Deploy Previews and rollbacks to your edge functions.
Edge Functions resources
Refer to the following resources to learn more about Netlify Edge Functions:
Or start building with one of our platform starters.
Netlify’s Background Functions provide an option for serverless functions that run for up to 15 minutes and don’t need to complete before a visitor can take next steps on your site. For tasks like batch processing, scraping, and slower API workflow execution, they may be a better fit than synchronous functions.
Learn more about Background Functions
Scheduled Functions is a feature of Netlify Functions that enables you to run functions on a regular and consistent schedule, much like a cron job. Scheduled functions can do almost anything that serverless functions do today, though some tasks are better suited to scheduled functions than others.
For example, you may want to:
Learn more about Scheduled Functions
With Netlify Image CDN, you can transform images on demand without impacting build times. Netlify Image CDN also handles content negotiation to use the most efficient image format for the requesting client. Optimizing the size and format of your images improves both the runtime performance and reliability of your site. Transformations are integrated natively into the CDN so that repeated requests leverage layers of caching for improved performance. Many frameworks on Netlify use Netlify Image CDN to power image optimization and transformation.
Image CDN resources
Refer to the following resources to learn more about Netlify Image CDN:
Or start building with one of our platform starters.
With Netlify Blobs, you can store and retrieve blobs and unstructured data. You can also use this feature as a simple key/value store or basic database.
Netlify Blobs is a highly-available data store optimized for frequent reads and infrequent writes.
For maximum flexibility, it offers a configurable consistency model. If multiple write calls to the same key are issued, the last write wins.
We automatically handle provisioning, configuration, and access control for you. This integrated zero-configuration solution helps you focus on building business value in your project rather than toil on setting up and scaling a separate blob storage solution.
Blobs resources
Refer to the following resources to learn more about Netlify Blobs:
Or start building with one of our platform starters.
Netlify’s global caching infrastructure is built to provide stellar performance without any stale pages or broken assets for your visitors.
We offer fine-grained cache control options to help you manage additional caching requirements. Three key patterns are stale while revalidate, durable cache for serverless function responses, and on-demand cache invalidation.
Stale while revalidate is a caching pattern that allows the cache to keep serving a stale object out of the cache while the object is revalidated in the background. This can be impactful for implementing API caching or patterns like incremental static regeneration (ISR).
As an example use case, imagine you have a slow API endpoint that takes 5 seconds to respond. You can wrap it in a function that adds the following cache header:
Netlify-CDN-Cache-Control: public, max-age=60, stale-while-revalidate=120
Here’s what this header does:
public
instructs Netlify’s edge to cache the first response.max-age=60
instructs the cache to continue serving the cached response for 60 seconds after the initial request. After 60 seconds, the cache is considered stale.stale-while-revalidate=120
instructs the cache how long it can serve stale content. If a request arrives within this specified duration after the content expired, the stale content is served while the cache revalidates the content in the background.If there’s a steady stream of requests, visitors will get recently refreshed results from the API without having to wait 5 seconds for the API response.
Here’s a timeline to illustrate how this works:
This is a pattern used by some frameworks, but can also be implemented directly.
Learn more about the stale while revalidate directive
By default, when a site visitor makes a request to Netlify for content that is generated by a function, the specific edge node the visitor connects to checks only its own local cache. If fresh content is not found in that node’s cache, the node invokes the function to generate a new response. This means the function is typically invoked multiple times for the same content.
To reduce function invocations and response latency, you can use the durable
directive for a function’s response. This makes it so that the response is not only returned to the edge node that invoked the function but also stored in a shared cache mechanism - the durable cache. Whenever that content is requested, edge nodes that don’t have the response locally cached check the durable cache, and only invoke a function if the response is not found there.
Learn more about the durable cache for serverless functions
If you want to invalidate cached objects while their cache control headers indicate they’re still fresh, you can purge the cache by site or cache tag. These granular options for refreshing your cache without redeploying your entire site optimize developer productivity for your team and site performance for your customers. On-demand invalidation across the entire network takes just a few seconds, even if you’re purging a tag associated with thousands of cached objects.
Learn more about on-demand cache invalidation
Your feedback helps us improve our docs.