ECT Header
Table of Content
The ECT (Effective Connection Type) header is used by HTTP applications to adapt to the network connectivity of a user. Designed to optimize web performance, ECT estimates network speed based on metrics such as round-trip time and bandwidth. This allows developers to programmatically alter the behavior of web applications according to the user's network conditions.
Syntax
ECT: 4G
The above is a basic sample of ECT header where the ECT is set to "4G".
Directives
The ECT header has 4 directives or connection types:
- 4G: High-speed internet with low latency.
- 3G: Moderate speed internet with slightly higher latency.
- 2G: Slow speed internet with high latency.
- slow-2G: Very slow internet with very high latency.
The value is set by the browser based on the user's real-time network conditions.
Examples
Examples of how to set the ECT header:
In JavaScript
:
navigator.connection.effectiveType
In HTTP
response header:
ECT: 3G
Browser Compatibility
Browser | Compatibility |
---|---|
Chrome | Supported |
Firefox | Not Supported |
Safari | Not Supported |
Opera | Supported |
Edge | Supported |
How to modify ECT header
The ModHeader Chrome extension is an effective tool to modify request headers like ECT. To use it:
- Install the ModHeader extension from the Chrome Web Store.
- Click the ModHeader icon in the toolbar and in the 'Request Headers' section, click 'Add'.
- Input 'ECT' in the name field, choose an effective connection type (e.g., '2G') in the value field, and save.
This capability to simulate different network conditions can help you optimize the performance of your web applications and provide enhanced user experiences.