Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 15, 2024 via pnpm

vary 1.1.2

Manipulate the HTTP Vary header
Package summary
Share
0
issues
1
license
1
MIT
Package created
4 Jun 2014
Version published
24 Sep 2017
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
vary@1.1.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
โ“˜ This is a list of vary 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does vary do?

The npm package "vary" is designed to manipulate the HTTP 'Vary' header. It is a helpful tool when dealing with HTTP caching, as it allows the server to communicate which headers it uses to determine how a response is generated. The 'Vary' header essentially aids in making HTTP caching more efficient.

How do you use vary?

To use the vary package, you first need to install it using npmโ€™s install command:

$ npm install vary

After its installation, you make use of it by requiring it within your JavaScript file:

var vary = require('vary');

Following this, if you have a header field that you want to add to the Vary response header, you can utilize the vary function:

// Appending "Origin" to the Vary header of the response
vary(res, 'Origin');

For an expanded perspective, if you're generating content based on a certain header, like the 'User-Agent' in this example, you can add it to the 'Vary' header for efficiency:

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

http.createServer(function onRequest (req, res) {
  // If you're about to user-agent sniff
  vary(res, 'User-Agent');

  var ua = req.headers['user-agent'] || '';
  var isMobile = /mobi|android|touch|mini/i.test(ua);

  // You may want to serve different content based on the user's device
  res.setHeader('Content-Type', 'text/html');
  res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user');
});

Where are the vary docs?

The documentation for the vary npm package can be found on its GitHub page. The README file on this page provides a detailed explanation of how to use the package, complete with installation steps and API documentation.