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

Front-end JavaScript operation principle

Table of contents 1. What is a JavaScript engine?...

Vue: Detailed explanation of memory leaks

What is a memory leak? A memory leak means that a...

Detailed explanation of Vue save automatic formatting line break

I searched for many ways to change it online but ...

Analyzing ab performance test results under Apache

I have always used Loadrunner to do performance t...

Do you know how to use vue-cropper to crop pictures in vue?

Table of contents 1. Installation: 2. Use: 3. Bui...

Windows cannot start MySQL service and reports error 1067 solution

Suddenly when I logged into MySQL, it said that a...

JS function call, apply and bind super detailed method

Table of contents JS function call, apply and bin...

Summary of MySQL InnoDB architecture

Table of contents introduction 1. Overall archite...

MySQL series of experience summary and analysis tutorials on NUll values

Table of contents 1. Test Data 2. The inconvenien...

Full process record of Nginx reverse proxy configuration

1. Preparation Install Tomcat on Linux system, us...

MySQL lock control concurrency method

Table of contents Preface 1. Optimistic Locking A...

mysql backup script and keep it for 7 days

Script requirements: Back up the MySQL database e...