HTTPREF
← Back to MIME types

MIME Type

Server-Sent Events (SSE)

API

Used for streaming real-time updates from a server to a client over HTTP.

MIME type reference, HTTP example, browser usage, common mistakes, and related content.

What is the text/event-stream MIME type?

The MIME type text/event-stream is used to tell browsers, APIs, and servers how a file or response body should be interpreted.

MIME stands for Multipurpose Internet Mail Extensions, and MIME types are now a standard part of HTTP responses and web content delivery.

When a browser or client receives a response with text/event-stream, it uses that information to decide how the content should be processed, rendered, downloaded, or executed.

Example

HTTP/1.1 200 OK
Content-Type: text/event-stream

data: Hello world

data: Another message

HTTP example

HTTP/1.1 200 OK
Content-Type: text/event-stream
Content-Length: 1256

Common use cases

  • Real-time notifications
  • Live dashboards
  • Streaming updates from APIs
  • Replacing polling with server push

Common mistakes

  • Using the wrong MIME type for the file being served
  • Returning text/plain instead of text/event-stream
  • Forgetting required parameters like charset when relevant
  • Using a deprecated MIME type in older server configurations
  • Serving assets with a mismatched Content-Type header, causing browser parsing issues

How browsers use it

Browsers use the Content-Type response header to decide how a response should be handled. For example, HTML is rendered as a page, CSS is parsed as styles, JavaScript is executed as script, and images are displayed visually. If the MIME type is incorrect, the browser may refuse to load the file correctly or may treat it as plain text or a download instead.

Practical developer insight

text/event-stream is used with Server-Sent Events (SSE). Unlike WebSockets, it is one-way from server to client and works over standard HTTP. Browsers also automatically reconnect when the stream is interrupted, which often surprises developers when debugging real-time behavior.

Related MIME types