fresh 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +38 -0
- package/{Readme.md → LICENSE} +2 -37
- package/README.md +58 -0
- package/index.js +8 -4
- package/package.json +29 -14
- package/.npmignore +0 -1
- package/History.md +0 -10
- package/Makefile +0 -7
package/HISTORY.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
0.3.0 / 2015-05-12
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* Add weak `ETag` matching support
|
|
5
|
+
|
|
6
|
+
0.2.4 / 2014-09-07
|
|
7
|
+
==================
|
|
8
|
+
|
|
9
|
+
* Support Node.js 0.6
|
|
10
|
+
|
|
11
|
+
0.2.3 / 2014-09-07
|
|
12
|
+
==================
|
|
13
|
+
|
|
14
|
+
* Move repository to jshttp
|
|
15
|
+
|
|
16
|
+
0.2.2 / 2014-02-19
|
|
17
|
+
==================
|
|
18
|
+
|
|
19
|
+
* Revert "Fix for blank page on Safari reload"
|
|
20
|
+
|
|
21
|
+
0.2.1 / 2014-01-29
|
|
22
|
+
==================
|
|
23
|
+
|
|
24
|
+
* Fix for blank page on Safari reload
|
|
25
|
+
|
|
26
|
+
0.2.0 / 2013-08-11
|
|
27
|
+
==================
|
|
28
|
+
|
|
29
|
+
* Return stale for `Cache-Control: no-cache`
|
|
30
|
+
|
|
31
|
+
0.1.0 / 2012-06-15
|
|
32
|
+
==================
|
|
33
|
+
* Add `If-None-Match: *` support
|
|
34
|
+
|
|
35
|
+
0.0.1 / 2012-06-10
|
|
36
|
+
==================
|
|
37
|
+
|
|
38
|
+
* Initial release
|
package/{Readme.md → LICENSE}
RENAMED
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
# node-fresh
|
|
3
|
-
|
|
4
|
-
HTTP response freshness testing
|
|
5
|
-
|
|
6
|
-
## fresh(req, res)
|
|
7
|
-
|
|
8
|
-
Check freshness of `req` and `res` headers.
|
|
9
|
-
|
|
10
|
-
When the cache is "fresh" __true__ is returned,
|
|
11
|
-
otherwise __false__ is returned to indicate that
|
|
12
|
-
the cache is now stale.
|
|
13
|
-
|
|
14
|
-
## Example:
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
var req = { 'if-none-match': 'tobi' };
|
|
18
|
-
var res = { 'etag': 'luna' };
|
|
19
|
-
fresh(req, res);
|
|
20
|
-
// => false
|
|
21
|
-
|
|
22
|
-
var req = { 'if-none-match': 'tobi' };
|
|
23
|
-
var res = { 'etag': 'tobi' };
|
|
24
|
-
fresh(req, res);
|
|
25
|
-
// => true
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Installation
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
$ npm install fresh
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## License
|
|
35
|
-
|
|
36
1
|
(The MIT License)
|
|
37
2
|
|
|
38
|
-
Copyright (c) 2012 TJ Holowaychuk
|
|
3
|
+
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
|
39
4
|
|
|
40
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
41
6
|
a copy of this software and associated documentation files (the
|
|
@@ -54,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
54
19
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
55
20
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
56
21
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
57
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# fresh
|
|
2
|
+
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![Node.js Version][node-version-image]][node-version-url]
|
|
6
|
+
[![Build Status][travis-image]][travis-url]
|
|
7
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
8
|
+
|
|
9
|
+
HTTP response freshness testing
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
$ npm install fresh
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
var fresh = require('fresh')
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### fresh(req, res)
|
|
24
|
+
|
|
25
|
+
Check freshness of `req` and `res` headers.
|
|
26
|
+
|
|
27
|
+
When the cache is "fresh" __true__ is returned,
|
|
28
|
+
otherwise __false__ is returned to indicate that
|
|
29
|
+
the cache is now stale.
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
var req = { 'if-none-match': 'tobi' };
|
|
35
|
+
var res = { 'etag': 'luna' };
|
|
36
|
+
fresh(req, res);
|
|
37
|
+
// => false
|
|
38
|
+
|
|
39
|
+
var req = { 'if-none-match': 'tobi' };
|
|
40
|
+
var res = { 'etag': 'tobi' };
|
|
41
|
+
fresh(req, res);
|
|
42
|
+
// => true
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
[MIT](LICENSE)
|
|
48
|
+
|
|
49
|
+
[npm-image]: https://img.shields.io/npm/v/fresh.svg
|
|
50
|
+
[npm-url]: https://npmjs.org/package/fresh
|
|
51
|
+
[node-version-image]: https://img.shields.io/node/v/fresh.svg
|
|
52
|
+
[node-version-url]: http://nodejs.org/download/
|
|
53
|
+
[travis-image]: https://img.shields.io/travis/jshttp/fresh/master.svg
|
|
54
|
+
[travis-url]: https://travis-ci.org/jshttp/fresh
|
|
55
|
+
[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh/master.svg
|
|
56
|
+
[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master
|
|
57
|
+
[downloads-image]: https://img.shields.io/npm/dm/fresh.svg
|
|
58
|
+
[downloads-url]: https://npmjs.org/package/fresh
|
package/index.js
CHANGED
|
@@ -33,14 +33,18 @@ function fresh(req, res) {
|
|
|
33
33
|
// unconditional request
|
|
34
34
|
if (!modifiedSince && !noneMatch) return false;
|
|
35
35
|
|
|
36
|
-
// check for no-cache
|
|
37
|
-
if (cc &&
|
|
36
|
+
// check for no-cache cache request directive
|
|
37
|
+
if (cc && cc.indexOf('no-cache') !== -1) return false;
|
|
38
38
|
|
|
39
39
|
// parse if-none-match
|
|
40
40
|
if (noneMatch) noneMatch = noneMatch.split(/ *, */);
|
|
41
41
|
|
|
42
42
|
// if-none-match
|
|
43
|
-
if (noneMatch)
|
|
43
|
+
if (noneMatch) {
|
|
44
|
+
etagMatches = noneMatch.some(function (match) {
|
|
45
|
+
return match === '*' || match === etag || match === 'W/' + etag;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
44
48
|
|
|
45
49
|
// if-modified-since
|
|
46
50
|
if (modifiedSince) {
|
|
@@ -50,4 +54,4 @@ function fresh(req, res) {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
return !! (etagMatches && notModified);
|
|
53
|
-
}
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fresh",
|
|
3
|
-
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
|
|
4
3
|
"description": "HTTP response freshness testing",
|
|
5
|
-
"version": "0.
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
8
|
+
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"fresh",
|
|
13
|
+
"http",
|
|
14
|
+
"conditional",
|
|
15
|
+
"cache"
|
|
16
|
+
],
|
|
17
|
+
"repository": "jshttp/fresh",
|
|
10
18
|
"devDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
19
|
+
"istanbul": "0.3.9",
|
|
20
|
+
"mocha": "1.21.5"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"HISTORY.md",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"index.js"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">= 0.6"
|
|
13
29
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
]
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "mocha --reporter spec --bail --check-leaks test/",
|
|
32
|
+
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
|
33
|
+
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
|
34
|
+
}
|
|
20
35
|
}
|
package/.npmignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
test
|
package/History.md
DELETED