What is forever-agent?
The forever-agent npm package is an HTTP/HTTPS Agent that keeps connection alive between requests. It is used primarily to reuse TCP connections in Node.js HTTP networking, which can lead to improved performance in some scenarios.
What are forever-agent's main functionalities?
Connection Reuse
This feature allows the agent to keep the TCP connection open for future requests to the same host, which can reduce the latency associated with establishing new TCP connections for each request.
const http = require('http');
const ForeverAgent = require('forever-agent');
const agent = new ForeverAgent();
http.request({
host: 'example.com',
agent: agent
});
Other packages similar to forever-agent
agentkeepalive
agentkeepalive is another npm package that provides similar functionality to forever-agent. It offers an HTTP and HTTPS Agent which keeps socket connections alive between keep-alive requests. It is more actively maintained and offers additional features such as per-host connection limiting.
got
got is a more comprehensive HTTP request library for Node.js that includes keep-alive functionality among many other features. It is designed to be a nicer and more user-friendly alternative to the built-in http module and includes retry support, stream support, and more.
forever-agent
HTTP Agent that keeps socket connections alive between keep-alive requests. Formerly part of mikeal/request, now a standalone module.