https://github.com/sv443/node.js-http-encoding-example
An example of how content encoding works in Node.js HTTP servers
https://github.com/sv443/node.js-http-encoding-example
brotli deflate encoding gzip html http http-server javascript js node nodejs website websites
Last synced: 7 months ago
JSON representation
An example of how content encoding works in Node.js HTTP servers
- Host: GitHub
- URL: https://github.com/sv443/node.js-http-encoding-example
- Owner: Sv443
- License: wtfpl
- Created: 2020-01-20T12:57:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-13T00:31:01.000Z (about 5 years ago)
- Last Synced: 2025-04-08T16:32:03.456Z (10 months ago)
- Topics: brotli, deflate, encoding, gzip, html, http, http-server, javascript, js, node, nodejs, website, websites
- Language: HTML
- Homepage:
- Size: 2.2 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Node.js HTTP Encoding Example
## This is an example of how content encoding works with Node.js HTTP servers
[WTFPL license](http://wtfpl.net/about/) - do whatever you wanna do with this code, you don't even have to credit me and there's no conditions whatsoever!
# Instructions to install and run:
Download or clone the repository and follow these steps to set up and run the HTTP server:
1. Make sure you have Node.js installed (minimum required Node version is `v11.7.0` - to find out your Node version, run `node -v` in a terminal)
2. Open a terminal in the folder that contains the `package.json` file and run the command `node .` or `npm start`
3. Open your browser and go to [http://localhost/](http://localhost/) or [http://127.0.0.1/](http://127.0.0.1/)
To stop the server, press ^C (CTRL + C)
# Info:
You don't need to install any dependencies - all the libraries are natively installed in Node.js.
This HTTP server example supports the encodings [Gzip](https://en.wikipedia.org/wiki/Gzip), [Deflate](https://en.wikipedia.org/wiki/DEFLATE) and [Brotli](https://en.wikipedia.org/wiki/Brotli).
It uses file streams to further increase page loading time (files don't need to be completely loaded to RAM and then sent but rather get directly piped to the client).
An example file called `test.html` is included, you can try modifying it if you want to (just remember to restart the server to see the changes).
If you need any help, feel free to [join my Discord server](https://sv443.net/discord) and I will gladly help you out.
You can find more information by looking at the [`index.js`](./index.js) file.