当前位置:网站首页>Static resource compression reduces bandwidth pressure and increases access speed
Static resource compression reduces bandwidth pressure and increases access speed
2022-06-28 07:35:00 【Huangyuewang】
If the picture is too large and blurred after compression , It is recommended to use picture segmentation to show ;
1. Manual compression
Css/JS/IMG Achieve compressed address : On-line JS/CSS/HTML Compress
2.Maven Auto pack compression Automatic generation .min file
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<!-- SpringBoot Integrate Web Components -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Build related configurations -->
<build>
<!-- maven The plug-in configuration -->
<plugins>
<plugin>
<!-- YUI Compressor Maven Compression plug-ins -->
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<!-- Read js,css Document adoption UTF-8 code -->
<encoding>UTF-8</encoding>
<!-- No display js Possible errors -->
<jswarn>false</jswarn>
<!-- If there are compressed files , Will first compare the source file for changes . If there are changes, compress , No compression without change -->
<force>false</force>
<!-- Insert a new row after the specified column number -->
<linebreakpos>-1</linebreakpos>
<!-- Perform aggregate file operation before compressing -->
<preProcessAggregates>true</preProcessAggregates>
<!-- Save the file suffix after compression -->
<suffix>.min</suffix>
<!-- Source directory , That is, the root directory to be compressed -->
<sourceDirectory>${basedir}/mobile</sourceDirectory>
<!-- Compress js and css file -->
<includes>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
<!-- The following directories and files will not be compressed -->
<excludes>
<exclude>**/*.min.js</exclude>
<exclude>**/*.min.css</exclude>
<exclude>scripts/data/*.js</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
mvn yuicompressor:compress3.Nginx Built in compression
stay server With code inside
gzip on;
gzip_buffers 32 4K;
gzip_comp_level 6;
gzip_min_length 100;
gzip_types application/javascript text/css text/xml;
gzip_disable "MSIE [1-6]\."; # Configuration disable gzip Conditions , Support regular . Here said ie6 And below are not enabled gzip( because ie Lower version not supported )
gzip_vary on;
The instructions are as follows :
Details of the configuration file
gzip Common parameters of configuration
gzip on|off; # Open or not gzip
gzip_buffers 32 4K| 16 8K # buffer ( Compress to buffer several blocks in memory ? How big is each piece ?)
gzip_comp_level [1-9] # recommend 6 Compression level ( The higher the level , The smaller the pressure , More wasteful CPU Computing resources )
gzip_disable # Regular matching UA Like what? Uri Don't make gzip
gzip_min_length 200 # Minimum length to start compression ( No matter how small it is, don't compress it , The point is not )
gzip_http_version 1.0|1.1 # Start compressing http Protocol version ( You can leave it blank , Now it's almost all 1.1 agreement )
gzip_proxied # Set up the requester proxy , How to cache content
gzip_types text/plain application/xml # For which types of files to compress Such as txt,xml,html ,css
gzip_vary on|off # Whether to transmit gzip Compress logo test :
Direct port access

go nginx visit :
Compressed 4 More than double
边栏推荐
- How bacnet/ip gateway collects data of building centralized control system
- ice, protobuf ,thrift -- 笔记
- 安全培训是员工最大的福利!2022新员工入职安全培训全员篇
- R language Kolmogorov Smirnov tests whether the two samples follow the same distribution.
- kubelet垃圾(退出的容器和未使用的镜像)回收源码分析
- LeetCode+ 51 - 55 回溯、动态规划专题
- golang gin框架进行分块传输
- ABAP skill tree
- The practice of event driven architecture in vivo content platform
- Sword finger offer II 091 Paint the house
猜你喜欢

腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者

Leetcode+ 66 - 70 high precision, two sub topics

Alibaba cloud server creates snapshots and rolls back disks

A gadget can write crawlers faster

8 figures | analyze Eureka's first synchronization registry

Leetcode+ 51 - 55 retrospective and dynamic planning topics

open62541直接导入NodeSet文件

LeetCode+ 66 - 70 高精度、二分专题

Kubelet garbage collection (exiting containers and unused images) source code analysis

Modifying MySQL user name root under Linux
随机推荐
Yesterday, I went to a large factory for an interview and asked me to do four arithmetic operations. Fortunately, I am smart enough
linux下修改mysql用户名root
Sword finger offer|: linked list (simple)
Pfizer's new Guankou medicine has entered the Chinese market, and the listing of relevant products of domestic pharmaceutical enterprises is just around the corner
Kubernetes deploys a secret pit where thanos ruler sends repeated alarms
What is the lifecycle of automated testing?
Solving the longest palindrome substring by dynamic programming
Leetcode+ 66 - 70 high precision, two sub topics
Ice, protobuf, thrift -- Notes
股票炒股注册开户靠谱吗?安全吗?
pip 更新到最新的版本
R 语言 Hitters 数据分析
kubelet驱逐机制的源码分析
Devtools implementation principle and performance analysis practice
MySQL installation steps - installing MySQL on Linux (3)
open62541直接导入NodeSet文件
NDK 交叉编译
es6箭头函数中return的用法
腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
PLC -- Notes