News & Announcements

Netlify presents: Edge Functions general availability

News & Announcements

Netlify presents: Edge Functions general availability

We are proud to announce the General Availability of Edge Functions, shipped with the production quality and reliability you expect from Netlify. Netlify Edge Functions connect the Netlify platform and workflow with an open-source, standards-based runtime at the network edge. This feature makes globalization, personalization, and authentication at the edge easier, faster, and more efficient to help your teams build better digital experiences that help you win more business.

Why Edge Functions?

The ability to personalize and globalize content based on geography, timezone, cookie settings, or request headers is critical for organizations looking to expand globally while remaining both compliant and competitive. Certain countries have regulatory requirements that apply to digital properties operating within their borders. Some folks value their privacy, and would like to decline cookie settings on webpages. And serving a website in a native language and running split tests to understand the effectiveness of web content is critical for attracting and converting new business.

When it comes to security, being able to authenticate at the edge removes the friction between maintaining access controls and enabling employees to access the tools they need to get their work done. Using Edge Functions, you can easily personalize your site experience based on the type of user who’s authenticated, or whether they’re an internal developer or an external user.

Edge Functions in action

Since we first launched the Beta program, we’ve been connecting with teams of all sizes to understand how we could improve Edge Functions to fit their needs. So, in addition to the features that developers have been using and loving, we are thrilled to announce some new highly-requested capabilities.

Response caching

In addition to the middleware-type scenarios of modifying the incoming request and/or the outgoing response, Edge functions can also be used as endpoints that deliver a full response back to the client. In these cases, and especially when the code runs intense computations or communicates with third-party APIs, it might be useful to cache the resulting responses and avoid invoking the edge function altogether on subsequent requests.
Now you can do just that. You can opt-in to caching by setting a new cache configuration property and then return the standard cache-control header in your responses.

import type { Context, Config } from "https://edge.netlify.com"

export default async (req: Request, context: Context) => {
  return new Response("Hello world", {
    headers: {
      "cache-control": "public, s-maxage=3600"
    }
  })
}

export const config: Config = {
  cache: "manual",
  path: "/hello"
}

For more information about response caching, refer to our documentation.

Exclusion paths

Since edge functions can be configured to run on multiple (or even all) URL paths, it’s sometimes useful to bypass the computation for a subset of them, depending on the use case.

If you need to make that decision based on information from each specific request like the client IP or geolocation, your edge function can terminate itself — and we made some improvements to this flow that you should use for optimal performance.

But if you know upfront that certain URL paths should never trigger the edge function, like static CSS or JavaScript files that should be served unmodified, you can now encode that configuration into the platform so that the edge function is never even evaluated.

import type { Config } from "https://edge.netlify.com"

export default async () => new Response("Hello, world!")

// Runs for all paths except *.css and *.js
export const config: Config = {
  path: "/*",
  excludedPath: ["/*.css", "/*.js"]
}

For more information about exclusion paths, refer to our documentation.

Custom error handling

The flexibility of edge functions makes them suitable for a wide range of use cases, from business-critical authentication/authorization mechanisms to nice-to-have site personalizations. Because an error that occurs during the execution of each of these edge functions has different consequences to the end user, we now let you define different error handling strategies.

Each edge function can now contain an onError configuration property that specifies whether an unhandled error should terminate the request with an error page, rewrite the request to a fallback path, or simply skip the erroring edge function and continue the request chain.

import { Config } from "https://edge.netlify.com"

export default async () => {
  await callExternalAPIThatMightFail()
}

export const config: Config = {
  path: "/external-api",
  onError: "/fallback"
}

For more information about custom error handling, refer to our documentation.

Plans and Pricing

Now that our Beta is ending, we wanted to let you know that we have some new pricing starting July 1, 2023.

For all existing and new Netlify Edge Functions users, the following pricing will go into effect for your July billing period:

Starter Pro Enterprise
Invocations included 1 million 2 million 5 million
Overages $2 per million $2 per million $2 per million (for higher usage - contact Sales)

If you aren't already using Edge Functions in your production environments, now is a good time to start so you can get a sense of how many invocations you’ll need at scale before pricing goes into effect in July.

To get a view of how many edge invocations you’re currently using, you can read more about Edge Functions usage and billing here.

Get started with Netlify Edge Functions

When it comes to Edge Functions, the possibilities are limitless. Whether you are a global brand looking to streamline your eCommerce experience through powerful customizations and simplified localization, or you’re just looking to make your static site more dynamic without sacrificing performance, Netlify Edge Functions can help. With Netlify Edge Functions, your team can maintain complete control, build better performing web experiences, and gain agility in their development process.

To get started with Edge Functions, head over to our docs and examples.

Are you already using Netlify Edge Functions and would like to give us your feedback? Drop us your feedback in the forums.

Not yet a Netlify customer, but ready to see Edge Functions in action? Request a demo today.

Keep reading

Recent posts

Book cover with the title Deliver web project 10 times faster with Jamstack enterprise

Deliver web projects 10× faster

Get the whitepaper