Skip to content

CDN Guide » WebSockets

Last updated: November 29, 2022

Introduction to WebSockets

WebSockets is 10+ years old technology for bidirectional, full-duplex communication between clients and server over a persistent TCP connection. All major browsers support WebSockets and server-side implementations are available for all well-known programming languages (Node, Python, Java etc).

The WebSocket client establishes an HTTP connection and requests to switch the protocol to WebSockets using the HTTP Upgrade mechanism. If the server supports WebSockets, the 'socket' connection is established and both the client and server can then send data to the other party.

Diagram: WebSockets Connection

WebSockets fits use cases where low latency, real-time communication between clients and server is required, like chat applications and multiplayer online gaming.

A Beginner's Guide to WebSockets

Dion Misic gave an excellent introductory talk about WebSockets at PyCon Australia in August 2018. Click the image below to watch his "A Beginner's Guide to WebSockets" on Youtube.

Video: A Beginner's Guide to WebSockets (29 minutes)

WebSockets references

CDNs and WebSockets

WebSockets data cannot be cached by the CDN (there is no 'request' and 'response'), so how do CDNs support and add value to customer apps that require WebSockets?

Does the CDN support proxying WebSockets traffic between client and origin?

Can you build and run a WebSockets app in the CDN edge platform, without an origin?

CDN comparison

Sort of/partially
Extra costs
Akamai More info
Bunny CDN
Cloudflare More info
CloudFront More info
Edgio More info
Fastly More info
Gcore More info
StackPath More info
CDNs missing in this table? That is because we don't have the relevant info

More info per CDN


Akamai can proxy WebSockets traffic. Read their Techdocs article WebSockets.


Cloudflare has supported WebSockets in a proxy mode since 2014. As of 2022, you can run origin-less WebSockets apps in their edge Workers platform. Read the WebSockets in Workers docs or the announcement on their blog


CloudFront supports WebSocket connections globally with no required additional configuration. More info in Using WebSockets with CloudFront distributions. The costs of using WebSockets on CloudFront is on the CloudFront pricing page, see sections "Amazon CloudFront to origin server" and "WebSocket pricing"


Edgio supports WebSockets on their traditional CDN (formerly Edgecast) but not in their AppOps platform (formerly Layer0)


Fastly supports WebSocket connections in a limited availability release. Customers must have a paid Fastly account. Billing for WebSockets on a combination of bandwidth and connection time. Read more on the Fastly WebSockets product page or - more technical - in the WebSockets passthrough article.


Gcore supports WebSocket connections globally on the CDN. WebSockets is enabled by default for whole-site delivery. Read more in the WebSockets. Allow WebSockets connections to an origin server article.


StackPath allows you to proxy your WebSocket connections through the CDN simply by enabling a setting in your CDN Stack. Read how in How-To Use WebSockets with the StackPath CDN. StackPath considers WebSocket traffic and HTTP traffic the same, therefore you will not be charged for ingress traffic and will be billed at your regular rate for egress traffic.

More CDN Guides