demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/fresh-0.5.2/README.md

Path
demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/fresh-0.5.2/README.md
Status
scanned
Type
file
Name
README.md
Extension
.md
Programming language

      
    
Mime type
text/plain
File type
exported SGML document, ASCII text
Tag

      
    
Rootfs path

      
    
Size
3374 (3.3 KB)
MD5
2409eba75b77a1b1258045cd372b4b6e
SHA1
d9a44594af9e00577bf6db57038dabd6ceed58a7
SHA256
ae9229e6a75e3f63f9cc1f651c6e1cafaedcc26852afe5ffed8a79c107b54aa5
SHA512

      
    
SHA1_git
1c1c680d151e5a64ab39cb88afc4600f554f00d5
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
README.md | 3.3 KB |

# fresh [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Node.js Version][node-version-image]][node-version-url] [![Build Status][travis-image]][travis-url] [![Test Coverage][coveralls-image]][coveralls-url] HTTP response freshness testing ## Installation This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): ``` $ npm install fresh ``` ## API <!-- eslint-disable no-unused-vars --> ```js var fresh = require('fresh') ``` ### fresh(reqHeaders, resHeaders) Check freshness of the response using request and response headers. When the response is still "fresh" in the client's cache `true` is returned, otherwise `false` is returned to indicate that the client cache is now stale and the full response should be sent. When a client sends the `Cache-Control: no-cache` request header to indicate an end-to-end reload request, this module will return `false` to make handling these requests transparent. ## Known Issues This module is designed to only follow the HTTP specifications, not to work-around all kinda of client bugs (especially since this module typically does not recieve enough information to understand what the client actually is). There is a known issue that in certain versions of Safari, Safari will incorrectly make a request that allows this module to validate freshness of the resource even when Safari does not have a representation of the resource in the cache. The module [jumanji](https://www.npmjs.com/package/jumanji) can be used in an Express application to work-around this issue and also provides links to further reading on this Safari bug. ## Example ### API usage <!-- eslint-disable no-redeclare, no-undef --> ```js var reqHeaders = { 'if-none-match': '"foo"' } var resHeaders = { 'etag': '"bar"' } fresh(reqHeaders, resHeaders) // => false var reqHeaders = { 'if-none-match': '"foo"' } var resHeaders = { 'etag': '"foo"' } fresh(reqHeaders, resHeaders) // => true ``` ### Using with Node.js http server ```js var fresh = require('fresh') var http = require('http') var server = http.createServer(function (req, res) { // perform server logic // ... including adding ETag / Last-Modified response headers if (isFresh(req, res)) { // client has a fresh copy of resource res.statusCode = 304 res.end() return } // send the resource res.statusCode = 200 res.end('hello, world!') }) function isFresh (req, res) { return fresh(req.headers, { 'etag': res.getHeader('ETag'), 'last-modified': res.getHeader('Last-Modified') }) } server.listen(3000) ``` ## License [MIT](LICENSE) [npm-image]: https://img.shields.io/npm/v/fresh.svg [npm-url]: https://npmjs.org/package/fresh [node-version-image]: https://img.shields.io/node/v/fresh.svg [node-version-url]: https://nodejs.org/en/ [travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg [travis-url]: https://travis-ci.org/jshttp/fresh [coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg [coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master [downloads-image]: https://img.shields.io/npm/dm/fresh.svg [downloads-url]: https://npmjs.org/package/fresh
Detected license expression
mit
Detected license expression (SPDX)
MIT
Percentage of license text
0.62
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
mit-bdcba66f-6e80-f7bd-7994-748183fe5693 mit MIT
URL Start line End line
https://nodejs.org/en 13 13
https://www.npmjs.com/ 14 14
https://docs.npmjs.com/getting-started/installing-npm-packages-locally 15 15
https://www.npmjs.com/package/jumanji 52 52
https://img.shields.io/npm/v/fresh.svg 110 110
https://npmjs.org/package/fresh 111 111
https://img.shields.io/node/v/fresh.svg 112 112
https://nodejs.org/en/ 113 113
https://img.shields.io/travis/jshttp/fresh/master.svg 114 114
https://travis-ci.org/jshttp/fresh 115 115
https://img.shields.io/coveralls/jshttp/fresh/master.svg 116 116
https://coveralls.io/r/jshttp/fresh?branch=master 117 117
https://img.shields.io/npm/dm/fresh.svg 118 118
Package URL License Primary language
pkg:npm/acme-demo-app@1.0.0 JavaScript
pkg:npm/fresh@0.5.2 mit JavaScript