Socket
Socket
Sign inDemoInstall

vary

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vary

Manipulate the HTTP Vary header


Version published
Weekly downloads
24M
decreased by-17.12%
Maintainers
3
Weekly downloads
 
Created

What is vary?

The vary npm package is a utility for manipulating the HTTP Vary header. It allows developers to programmatically append values to the Vary header of an HTTP response, ensuring that the correct header is constructed for proper handling of HTTP caching, content negotiation, and other mechanisms that might vary the response based on certain aspects of the request.

What are vary's main functionalities?

Appending to the Vary header

This feature allows you to append a field to the Vary header of an HTTP response. In the code sample, the 'User-Agent' field is added to the Vary header, indicating that the response may vary based on the 'User-Agent' header of the request.

"use strict";

const http = require('http');
const vary = require('vary');

http.createServer((req, res) => {
  vary(res, 'User-Agent');
  res.end('Response varies based on User-Agent header.');
}).listen(3000);

Appending multiple fields

This feature allows you to append multiple fields to the Vary header at once. In the code sample, both 'User-Agent' and 'Accept-Encoding' are added to the Vary header, indicating that the response may vary based on both of these request headers.

"use strict";

const http = require('http');
const vary = require('vary');

http.createServer((req, res) => {
  vary(res, 'User-Agent, Accept-Encoding');
  res.end('Response varies based on User-Agent and Accept-Encoding headers.');
}).listen(3000);

Other packages similar to vary

Keywords

FAQs

Package last updated on 09 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc