How to implement web page compression in Nginx optimization service

How to implement web page compression in Nginx optimization service

Configure web page compression to save resources

1. First, let's modify the configuration

vim /usr/local/nginx/conf/nginx.conf
http {
......
  gzip on; #Uncomment and enable gzip compression function gzip_min_length 1k; #Minimum compressed file size gzip_buffers 4 64k; #Compression buffer, size is 4 64k buffers gzip_http_version 1.1; #Compression version (default 1.1, if the front end is squid2.5, please use 1.0)
  gzip_comp_level 6; #Compression ratio gzip_vary on; #Support front-end cache server to store compressed pages gzip_types test/plain text/javascript application/x-javascript text/css text/xml application/xml application/xml+rss
  image/jpg image/jpeg image/png image/gif application/x-httpd-php application/javascript application/json;
  #Compression type, indicating which web documents enable compression function......
} 

insert image description here

insert image description here

2. Drag the pictures we need to display into the folder

insert image description here

3. Insert this picture into the web page

vim index.html
......
<img src="game.jpg"/> #Insert pictures into the webpage</body>
</html> 

insert image description here

4. Restart the service

insert image description here

5. Check in the element and find that it has been compressed

insert image description here

This is the end of this article about Nginx optimization service web page compression. For more relevant Nginx web page compression content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • nginx basic tutorial
  • Nginx Configuration Getting Started Tutorial
  • Getting Started Tutorial on nginx HTTP Server under Windows
  • What is Nginx load balancing and how to configure it
  • Six methods for nginx optimization
  • Detailed explanation of how Nginx solves the problem of cross-domain access to front-end resources
  • Solve the problem of Nginx returning 404 after configuring proxy_pass
  • Limiting the number of short-term accesses to a certain IP based on Nginx
  • Nginx configuration and compatibility with HTTP implementation code analysis
  • Nginx Service Quick Start Tutorial

<<:  Detailed explanation of MySQL Workbench usage tutorial

>>:  W3C Tutorial (12): W3C Soap Activity

Recommend

Eight hook functions in the Vue life cycle camera

Table of contents 1. beforeCreate and created fun...

Some tips on deep optimization to improve website access speed

Some tips for deep optimization to improve websit...

Using nginx + fastcgi to implement image recognition server

background A specific device is used to perform i...

Implementation of nginx proxy port 80 to port 443

The nginx.conf configuration file is as follows u...

Nginx try_files directive usage examples

Nginx's configuration syntax is flexible and ...

How to add a pop-up bottom action button for element-ui's Select and Cascader

As shown in the figure below, it is a common desi...

MySQL 5.7.23 decompression version installation tutorial with pictures and text

Download the MySQL installer Official download ad...

Springboot+VUE to realize login and registration

This article example shares the specific code of ...

MySQL 8.X installation tutorial under Windows

I had been using MySQL 5.7 before, but because My...

JavaScript to implement login slider verification

This article example shares the specific code of ...

Summary of the 10 most frequently asked questions in Linux interviews

Preface If you are going to interview for a Linux...

JS implements array filtering from simple to multi-condition filtering

Table of contents Single condition single data fi...