当前位置:网站首页>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
边栏推荐
猜你喜欢

kubernetes删除pod的流程的源码简析

Construction and exploration of vivo database and storage platform

Leetcode learning records

剑指Offer||:链表(简单)

ACM notes

The practice of traffic and data isolation in vivo Reviews

The practice of event driven architecture in vivo content platform

Design and implementation of spark offline development framework

LeetCode+ 51 - 55 回溯、动态规划专题

MySQL installation steps - how to create a virtual machine under Linux (1)
随机推荐
Code submission specification
Is it safe to open an account on Dongfang fortune
Leetcode learning records
linux下修改mysql用户名root
阿里云服务器创建快照、回滚磁盘
R language drawing ggplot2 seasonal graph
Top 25 most popular articles on vivo Internet technology in 2021
R 语言 ggmap 可视化集群
R language Kolmogorov Smirnov tests whether the two samples follow the same distribution.
一个小工具可以更快的写爬虫
Kubernetes deploys a secret pit where thanos ruler sends repeated alarms
R language ggmap
云原生(待更新)
小小一款代码编辑器竟然也可以有程序运行之功能——Sublime Text3运行各种语言程序的总结
Unity-UI-shadow组件
逆波兰表达式求值<难度系数>
What is the lifecycle of automated testing?
kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑
Encyclopedia of scala operators
Cloud native (to be updated)