diff --git a/README.md b/README.md index b7348f5..eca6c47 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,29 @@ ex-static ========= -**WARNING: DO NOT USE ON LARGE FILES!** -`ex-static` keeps all file data in memory and so is not recommended for files larger than a megabyte (unless you have a lot of spare RAM). -Now also watches files for changes and reloads them when needed. +Serves files. It's pretty fast. ### To use: ```javascript var http = require('http'); var static = require('ex-static'); -var staticFiles = [ +var files = [ {url: '/', path: 'static/index.html'}, - {url: '/test.jar', path: 'static/test.jar', type: 'application/java-archive', cache: -1, compress: true} + {url: '/test.jar', path: 'static/test.jar', type: 'application/java-archive', cache: 300000, compress: true} ]; -http.createServer(staticFiles).listen(80); +http.createServer(static(files)).listen(80); ``` -The `cache` parameter sets the number of seconds on the `Cache-Control: max-age` header. Using -1 sets a very large value while using 0 sets no header. +* `cache` - Sets the number of seconds on the `Cache-Control: max-age` header. Using 0 sets no header. +* `type` - Used to specify a `Content-Type`, or override the default type associated with the file extension. +* `compress` - Set whether we should use compression. Small files have it on by default. +* `stream` - True if the file should be streamed to the client, false if it should be written in one chunk. Defaults to true for small files. +* `path` - The local file path where the file can be found. +* `url` - The url where the file should be served. + + All files have `ETag` values that are the MD5 hashes of their contents. -`type` is used to specify a `Content-Type`, or override the default type associated with the file extension. -All `text/*` files are compressed with `gzip` for browsers that support it. To override the default compression setting for a file, use the `compress` parameter. - -`ex-static` also supports automatic revving of HTML files. -Any instance of the string `{rev}` in an HTML file will be replaced with a timestamp when the static server starts up. -This is useful for ensuring that users have the latest version of a file even if the `cache` option is enabled. -### Example: -```html - - - - - - - -``` + +Small files are compressed with gzip for browsers that support it. To override the default compression setting for a file, use the `compress` parameter. diff --git a/package.json b/package.json index ef42ce0..ec559ec 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,21 @@ { "name": "ex-static", "description": "Fast, static file server middleware with built-in revving", - "version": "0.3.0", + "version": "0.4.0", "author": "download ", "main": "static", "scripts": { - "test": "moka" + "test": "mocha" }, "repository": { "type": "git", - "url": "https://github.com/download13/static" + "url": "https://github.com/download13/ex-static" }, "dependencies": { "mime": "1.x.x" }, "devDependencies": { - "moka": "*", - "expect.js": "*" + "mocha": "*" }, "engine": { "node": "*"