当前位置:网站首页>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
边栏推荐
- DOM parsing of XML file case code sentence by sentence analysis
- MySQL master-slave replication, detailed configuration, create unable to connect processing prompt
- 7-1 understand everything
- Uninstall and reinstall the latest version of MySQL database. The test is valid
- 力扣515.在每棵树行中找最大值
- Llvm and clang
- 安全培训是员工最大的福利!2022新员工入职安全培训全员篇
- In idea, the get and set methods may be popular because the Lombok plug-in is not installed
- What should I do if the version is incompatible with the jar package conflict?
- MySQL installation steps - Linux configuration file JDK installation (II)
猜你喜欢

kubelet垃圾(退出的容器和未使用的镜像)回收源码分析

goland IDE和delve调试位于kubernetes集群中的go程序

What is a consistent hash? What scenarios can it be applied to?

Unity-UI-shadow组件

看似简单的光耦电路,实际使用中应该注意些什么?

SQL statement optimization steps (1)

网传互联网公司加班表,排名第一的没悬念

分析 NFT 项目的 5 个指标

Jinshan cloud team shared | 5000 words to understand how Presto matches with alluxio

BACnet/IP网关如何采集楼宇集中控制系统数据
随机推荐
Modifying MySQL user name root under Linux
推荐系统系列精讲(第五讲): 排序模型的调优实践
剑指Offer||:链表(简单)
Ice, protobuf, thrift -- Notes
"Three routines" of digital collection market
Kubernetes deploys a secret pit where thanos ruler sends repeated alarms
ACM notes
8 figures | analyze Eureka's first synchronization registry
Using interceptor and cache to complete interface anti brushing operation
Face to face experience --- test engineer web side automation --- interview questions for large factories
Hack the box:routerspace
Cloud native (to be updated)
R 语言绘制 动画气泡图
vite2.9 中指定路径别名
Principle and practice of bytecode reference detection
云原生(待更新)
What is the lifecycle of automated testing?
自动化测试的生命周期是什么?
Alibaba cloud server creates snapshots and rolls back disks
pip 更新到最新的版本