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

Examples of using MySQL covering indexes

What is a covering index? Creating an index that ...

In-depth understanding of Worker threads in Node.js

Table of contents Overview The history of CPU-bou...

How to view files in Docker image

How to view files in a docker image 1. If it is a...

Vue calls the PC camera to realize the photo function

This article example shares the specific code of ...

Memcached method for building cache server

Preface Many web applications store data in a rel...

How to automatically import Vue components on demand

Table of contents Global Registration Partial Reg...

Data storage implementation method in WeChat applet

Table of contents Global variable globalData Page...

Example of fork and mutex lock process in Linux multithreading

Table of contents Question: 1. First attempt 2. R...

Vue routing lazy loading details

Table of contents 1. What is lazy loading of rout...

html page!--[if IE]...![endif]--Detailed introduction to usage

Copy code The code is as follows: <!--[if IE]&...

Implementation example of scan code payment in vue project (with demo)

Table of contents Demand background Thought Analy...

MySQL GROUP_CONCAT limitation solution

effect: The GROUP_CONCAT function can concatenate...

js implements mouse switching pictures (without timer)

This article example shares the specific code of ...