Skip to content

Commit

Permalink
disableEtag --> disableETag
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Sep 3, 2016
1 parent 7f17e6e commit 23c9e59
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
$ npm i koa-static-serve
```


## Examples

View the [./examples](examples) directory for working examples.

## API

Expand All @@ -28,7 +30,16 @@ const app = new Koa();
const serve = require('koa-static-serve');
const staticPath = path.join(__dirname, '..');
app.use(serve(staticPath, {
maxAge : 600
maxAge: 3600,
sMaxAge: 600,
headers: {
'X-Server': 'koa-static-serve',
},
dotfiles: 'allow',
denyQuerystring: true,
disableETag: true,
disableLastModified: true,
'404': 'next',
}));
const port = process.env.PORT || 10000;
app.listen(port);
Expand All @@ -51,7 +62,7 @@ console.dir('server listen on:' + port);

- `charset` default content charset

- `disableEtag` disable etag header
- `disableETag` disable etag header

- `disableLastModified` disable last-modified header

Expand Down
11 changes: 10 additions & 1 deletion examples/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ const app = new Koa();
const serve = require('../lib/serve');
const staticPath = path.join(__dirname, '../assets');
app.use(serve(staticPath, {
maxAge : 600
maxAge: 3600,
sMaxAge: 600,
headers: {
'X-Server': 'koa-static-serve',
},
dotfiles: 'allow',
denyQuerystring: true,
disableETag: true,
disableLastModified: true,
'404': 'next',
}));
const port = process.env.PORT || 10000;
app.listen(port);
Expand Down
2 changes: 1 addition & 1 deletion lib/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function serve(staticPath, options) {
const type = mime.lookup(file);
const charset = mime.charsets.lookup(type) || defaultCharset;
const headers = getHeaders();
if (!options || !options.disableEtag) {
if (!options || !options.disableETag) {
headers.ETag = etag(stats);
}
if (!options || !options.disableLastModified) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koa-static-serve",
"description": "static serve middlware for koa",
"version": "2.0.7",
"version": "2.0.8",
"author": "Tree Xie <vicansocanbico@gmail.com>",
"keywords": [
"koa",
Expand Down
2 changes: 1 addition & 1 deletion test/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('serve', function() {
it('should disable ETag', done => {
const app = new Koa();
app.use(serve(assets, {
disableEtag: true,
disableETag: true,
}));
request(app.listen())
.get('/test.js')
Expand Down

0 comments on commit 23c9e59

Please sign in to comment.