before use
After use
method
webpack configuration Compression-webpack-plugin compresses gzip files
Function: Improve network transmission rate -> optimize web page loading time
Fundamental
- When the browser requests a resource file, it will automatically include an Accept-Encoding request header to tell the server what compression encoding type it supports.
- Server configuration turns on the gzip option: when receiving a client resource file request, check the compression encoding format supported by the request header Content-encoding. If it contains gzip, perform gzip encoding and compression before each response to the resource request and then respond to the resource file (in the response The header will carry Content-encoding: gzip)
- After receiving the response, the browser checks whether the request header contains Content-encoding:gzip. If so, it decompresses the returned resource file and then parses and renders it.
Specific use
1.Install the plug-in
1 |
|
2. Configure the plug-in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
or
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
3.nginx configuration
1 2 3 4 5 6 7 8 9 10 11 |
|
The above are the details of the specific usage of gzip compression when packaging vue projects. For more information about gzip compression when packaging vue, please pay attention to other related articles!
Four ways to judge whether two arrays have the same elements in js/Four ways to judge whether two arrays have the same elements in js/Four ways to judge whether two arrays have the same elements in js/Js to judge whether two arrays have the same elements Four methods of elements