I asked this question several times and deleted it, and after searching separately, I found out that the process I wanted was compression transmission. So the conclusion is
I want to know about the compression transmission method using gzip. I don't know because I haven't learned anything.
node.js javascript css
The gzip is handled by Web Server Settings. If you're using Apache, read this article if you're using NGINX, read this article.
Just to give you the basics
https://nodejs.org/api/zlib.html
You can use zlib
Pipe to a file stream object that reads a file You can connect gzip and response objects sequentially.
And in order to get it right on your browser,
Write 'Content-Encoding':'gzip'
for the response header value.
const zlib = require('zlib');
const http = require('http');
const fs = require('fs');
http.createServer((request, response) => {
const raw = fs.createReadStream('something.js');
response.writeHead(200, { 'Content-Encoding': 'gzip' });
raw.pipe(zlib.createGzip()).pipe(response);
}).listen(3000);
All this is possible with nodes alone, of course
At the actual service level, the additional settings for these static resources are: As @Yupto-gun said, it is more common to process it with a web server setting.
579 Understanding How to Configure Google API Key
585 PHP ssh2_scp_send fails to send files as intended
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
631 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.