You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

8 years ago
  1. # fresh
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Node.js Version][node-version-image]][node-version-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. HTTP response freshness testing
  8. ## Installation
  9. ```
  10. $ npm install fresh
  11. ```
  12. ## API
  13. ```js
  14. var fresh = require('fresh')
  15. ```
  16. ### fresh(req, res)
  17. Check freshness of `req` and `res` headers.
  18. When the cache is "fresh" __true__ is returned,
  19. otherwise __false__ is returned to indicate that
  20. the cache is now stale.
  21. ## Example
  22. ```js
  23. var req = { 'if-none-match': 'tobi' };
  24. var res = { 'etag': 'luna' };
  25. fresh(req, res);
  26. // => false
  27. var req = { 'if-none-match': 'tobi' };
  28. var res = { 'etag': 'tobi' };
  29. fresh(req, res);
  30. // => true
  31. ```
  32. ## License
  33. [MIT](LICENSE)
  34. [npm-image]: https://img.shields.io/npm/v/fresh.svg?style=flat
  35. [npm-url]: https://npmjs.org/package/fresh
  36. [node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
  37. [node-version-url]: http://nodejs.org/download/
  38. [travis-image]: https://img.shields.io/travis/jshttp/fresh.svg?style=flat
  39. [travis-url]: https://travis-ci.org/jshttp/fresh
  40. [coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh.svg?style=flat
  41. [coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master
  42. [downloads-image]: https://img.shields.io/npm/dm/fresh.svg?style=flat
  43. [downloads-url]: https://npmjs.org/package/fresh