Koa.js Compression - Koa.js

What is Koa.js Compression?

Compression facilitates in increasing the speed of the speed of the website and saving the bandwidth. Only the modern browsers are compatible with Compression. Using Compression to send responses from the server, results in load time improvement.

How to install Koa.js Compression?

Koa-compress middleware is used in Koa for compression of files and appropriately setting headers.

Koa-compress is installed by:

In app.js file, enter the code:

By the code, the compression middleware is installed. Filter option function decide to compress or not after checking the type of response content. Threshold option is the size of the response to compress in bytes.

For instance, a response without compression appears as:

Response without Compression

The same response with compression appears as:

Response with Compression

The size tab at bottom displays the difference between the response without compression and the response with compression. Compression of the files results in 150% improvement.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Koa.js Topics