Service Extensions lets you use extensions to insert custom code in the Media CDN processing path. This page provides an overview about Media CDN extensions.
Media CDN provides many built-in core capabilities to address the most common use cases for content delivery networks (CDNs). You might have requirements beyond these capabilities. For example, you might need to normalize headers to improve caching, use a custom URL signing algorithm, or port legacy behavior from an existing CDN to Media CDN.
You can use edge extensions (CdnEdgeExtension) to run WebAssembly (Wasm)
plugins directly at the Google edge
network in front of the cache in the Media CDN processing path.
A CdnEdgeExtension resource attaches directly to an EdgeCacheService
deployment and runs one or more ordered extension chains (extensionChains).
Each extension chain defines Common Expression Language (CEL) match
conditions (matchCondition.celExpression) to selectively evaluate requests
based on hostnames, URL paths, query parameters, or HTTP request headers.
Plugins can access and manipulate both HTTP request headers and response headers, influence cache key generation, validate custom authorization tokens or URL signatures, and serve synthetic responses. For more information, see Figure 1.
How Media CDN edge extensions work
When a client request reaches an EdgeCacheService that's extended by an edge
extension, the extension runs in the following sequence:
Match condition evaluation: Media CDN extracts request attributes and evaluates the ordered
extensionChainsdefined in theCdnEdgeExtension. The first chain whose CEL expression evaluates totrueruns, and all subsequent chains are skipped.Plugin request header processing (
REQUEST_HEADERS): your configured plugins run sequentially. You can chain a maximum of two plugins within a single extension chain. Plugins can inspect forwarded HTTP headers and Envoy attributes, add or rewrite request headers, or return a direct synthetic response to the client.Route matching and origin selection: Media CDN evaluates route rules and then selects the target origin based on the request, including any request headers or URL paths that the plugins modified.
Cache lookup and origin fetch: Media CDN evaluates cache keys (which can incorporate request headers or URL paths that the plugins modified), checks edge cache storage, and serves content when a cache hit occurs or fetches content from the selected origin when a cache miss occurs.
Plugin response header processing (
RESPONSE_HEADERS): after content is retrieved from either the cache or the origin, your configured plugins run sequentially. Then, the modified response headers are delivered to the downstream client.Delivery to client: the final response headers and body are delivered to the client.