Socket
Socket
Sign inDemoInstall

fresh

Package Overview
Dependencies
0
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fresh

HTTP response freshness testing


Version published
Weekly downloads
21M
decreased by-24.63%
Maintainers
4
Install size
5.74 kB
Created
Weekly downloads
 

Package description

What is fresh?

The 'fresh' npm package is a HTTP response freshness testing library. It is used to determine whether the response is still 'fresh' in the context of HTTP caching. It checks the request and response headers to decide if the response should be re-used or if a new one needs to be generated.

What are fresh's main functionalities?

Freshness Checking

This feature allows you to check if the HTTP response is still fresh by comparing the request and response headers. If the function returns true, the response is considered fresh.

const fresh = require('fresh');

const reqHeaders = { 'if-none-match': 'some-etag' };
const resHeaders = { 'etag': 'some-etag' };

const isFresh = fresh(reqHeaders, resHeaders);
console.log(isFresh); // true or false

Other packages similar to fresh

Readme

Source

fresh

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

HTTP response freshness testing

Installation

$ npm install fresh

API

var fresh = require('fresh')

fresh(req, res)

Check freshness of req and res headers.

When the cache is "fresh" true is returned, otherwise false is returned to indicate that the cache is now stale.

Example

var req = { 'if-none-match': 'tobi' };
var res = { 'etag': 'luna' };
fresh(req, res);
// => false

var req = { 'if-none-match': 'tobi' };
var res = { 'etag': 'tobi' };
fresh(req, res);
// => true

License

MIT

Keywords

FAQs

Last updated on 08 Sep 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc