From 6fb96c50b7a18caf752faa4d1f9a9520d4ef1329 Mon Sep 17 00:00:00 2001 From: Doug Wade Date: Tue, 5 Sep 2017 22:01:53 -0700 Subject: [PATCH] [#16] Remove spdy from docs --- README.md | 3 +- docs/faq.md | 2 +- docs/file-serving.md | 18 ------ docs/polyfills.md | 6 -- docs/spdy.md | 137 ------------------------------------------- 5 files changed, 2 insertions(+), 164 deletions(-) delete mode 100644 docs/spdy.md diff --git a/README.md b/README.md index 827df64..96c4858 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,7 @@ The Koala framework adds to Koa: - Supports JSON, urlencoded, and multipart bodies - Supports arbitrary strings, buffers, and files as bodies - Optional nested parameter support -- [SPDY](docs/spdy.md) - specifically push streams -- [File Serving](docs/file-serving.md) - with SPDY push support +- [File Serving](docs/file-serving.md) - [Sessions](docs/sessions.md) - Cookie-based sessions - CSRF protection diff --git a/docs/faq.md b/docs/faq.md index 7be9ceb..672918b 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -32,7 +32,7 @@ With Koa, it's easier as well as better to do atomic updates. For example, if you use MongoDB, you might want to do something like: https://github.com/aheckmann/koa-mongodb-session/issues/5. -## Will other SPDY and HTTP/2 features be supported? +## Will other HTTP/2 features be supported? A lot of these features belong at the `http.createServer()` state of deploying your app, which Koala does not handle. diff --git a/docs/file-serving.md b/docs/file-serving.md index fe00121..6a41976 100644 --- a/docs/file-serving.md +++ b/docs/file-serving.md @@ -15,7 +15,6 @@ Don't try to juggle multiple static folders. Some features of this static server: -- SPDY push support - Creates strong `sha256` etags and caches them - Caches `fs.stat()` calls - Caches gzipped versions of these files @@ -34,20 +33,3 @@ var app = koala({ } }) ``` - -## var file = yield* this.fileServer.push(path, [options]) - -SPDY push a file from the folder. -`path` must be relative without the leading `/`. -Errors will be thrown on unknown files. -The only `option` is `priority: 7`. - -`yield*` is required here because it uses an `fs.stat()` call -to make sure the file exists. -`yield` again and it'll wait until the file has finished being pushed. - -```js -app.use(function* (next) { - yield* this.fileServer.push('favicon.ico') -}) -``` diff --git a/docs/polyfills.md b/docs/polyfills.md index f657fcd..a84415b 100644 --- a/docs/polyfills.md +++ b/docs/polyfills.md @@ -18,9 +18,3 @@ client's user-agent, giving them only what they need. Add `` to your page, and the appropriate polyfills will be used on the page. - -### [yield] this.polyfills.push() - -To avoid that extra HTTP request delay, -SPDY push `polyfill.js` so your page loads as fast as possible. -You only need to do this when you serve HTML pages that have the script tag. diff --git a/docs/spdy.md b/docs/spdy.md deleted file mode 100644 index 992a200..0000000 --- a/docs/spdy.md +++ /dev/null @@ -1,137 +0,0 @@ - -## SPDY - -Koala adds some SPDY support to Koa. -Once SPDY becomes an HTTP standard and is baked into node.js, -some of these features will be placed in Koa. - -### this.isSpdy - -Check whether SPDY is supported. - -```js -app.use(function* (next) { - if (this.isSpdy) { - this.push('/some-file.js', { - filename: __dirname + '/some-file.js' - }); - } - - yield* next; -}) -``` - -### [yield] this.push([path], options, [priority]) - -SPDY push a body. -This is a wrapper around [node-spdy push streams](https://github.com/indutny/node-spdy#push-streams), -allowing you to not think about stream acknowledgement, -error handling, and file descriptor leaks. -[spdy-push](https://github.com/jshttp/spdy-push) is used under the hood. - -- `path` - the path of the push stream -- `priority: 7` - the priority of the push stream. `0` is highest, `7` is lowest. -- `options`: - - `path` if not set as an argument - - `priority: 7` if not set as an argument - - `body` - the body of the stream as a string, buffer, or stream - - `filename` - the absolute path of the source file - - `headers` - the headers for the stream - -Either set `options.body` or `options.filename`. -The following headers will automatically be set if possible: - -- `content-length` - unless the body is a stream or `filename` -- `content-encoding` -- `content-type` - based on `path` - -Argument order does not matter, so use whatever is convenient. - -```js -app.use(function* () { - this.push({ - path: '/index.js', - filename: path.resolve('public/index.js'), - headers: { - 'cache-control': 'public, max-age=999999999999' - } - }) -}) -``` - -You may optionally `yield this.push()`. -This yields until the push stream is finished. -You may want this to avoid some issues with push streams. - -### Setup SPDY server - -Since [node-spdy](https://github.com/indutny/node-spdy) is optional dependency. You need install it by yourself `npm install spdy --save`. - -SPDY server is compatible with https module and fallback to regular https (for browsers that don't support SPDY yet). - -Imagine you're building a single page web site. - -```js -app.use(function* () { - yield this.fileServer.send('index.html'); - if (this.isSpdy) { - yield this.push('/some-file.js', { - filename: __dirname + '/some-file.js' - }); - yield this.fileServer.push('css/all.css'); // or better use fileServer.push - yield this.fileServer.push('img/logo.png'); // push image resources - yield this.polyfills.push(); // polyfills support push also - } -}); - -var spdy = require('spdy'), - fs = require('fs'); - -var server = spdy.createServer({ - key: fs.readFileSync('server.key'), - cert: fs.readFileSync('server.crt'), - ca: fs.readFileSync('server.csr') -}, app.callback()); - -server.listen(3000); -``` - -Open chrome(27+) visit . Server logs like this: - -``` - <-- GET / - --> GET / 200 302ms 367b -``` - -If you visit with other old browser without spdy support. The logs maybe like this: - -``` - <-- GET / - --> GET / 200 76ms 367b - <-- GET /css/all.css - --> GET /css/all.css 200 16ms 32.73kb - <-- GET /js/polyfill.js - --> GET /js/polyfill.js 200 20ms - - <-- GET /some-file.js - --> GET /some-file.js 200 15ms - - <-- GET /img/logo.png - --> GET /img/logo.png 200 29ms 29.89kb -``` - -SPDY can help you reuse http connection. Send more data in one request. - -> Its goal is to reduce the latency of web pages. --- - -### self-signed SSL Certificate - -For testing purposes. We need self-signed SSL certificate to boot up SPDY server. - -An easily way is install [spdy-keys](https://github.com/normalize/spdy-keys). - -```js -var keys = require('spdy-keys'); - -spdy.createServer(keys, app.callback()); -``` - -If you want to create keys by yourself. Read [How to create a self-signed SSL Certificate ...](http://www.akadia.com/services/ssh_test_certificate.html)