Website performance optimization-enable http compression on the server side and Performance Optimization on the server side
Due to some management and development problems in a company project, after the development is completed, a js file will become very large, and there will be kb after minimize, which affects the website performance, especially when the network speed is slow, loading a page takes 2 minutes. A lot of complaints from customers...
The best way to solve this problem is to break down the large js file and load only the required javascript. However, since the original developers are no longer there, this decomposition task has a high risk factor and cannot be tried easily (the customer has a high requirement and it is difficult to explain it to the customer once an error occurs ). In order to improve the website response time at a low speed, I thought of using the server to compress http Response content to reduce network data transmission.
IIS 7.0 improves the server compression method to make it easier to configure and use.
Here is a detailed introduction of Microsoft official website and configuration https://www.iis.net/configreference/system.webserver/httpcompression
IIS 7.0 and later versions provide two compression methods:
1. Static Compression: compresses static content on the server, such as *. js and *. css. It will cache the Compressed content to the following path: % windir % \ inetpub \ temp \ IIS Temporary Compressed Files \ ApplicationPool \
2. Dynamic Compression: compresses the dynamically generated content on the server, such as *. aspx. After dynamic compression is enabled, the server compresses the dynamic content each time before it outputs the dynamic content to consume resources.
IIS 7.0 and later support two compression methods:
1. Deflate: the compression rate is higher than that of Gzip, but there are not many platforms that support Deflate except browsers.
2. Gzip (GNU zip): We recommend that you set this compression method.
How to enable Gzip compression by modifying web. config
ApplicationHost. config is an IIS configuration file introduced after IIS 7.0. For more information, see the official link http://www.iis.net/learn/get-started/planning-your-iis-architecture/introduction-to-applicationhostconfig
Location of the file % windir % \ system32 \ inetsrv \ config
The configuration of http compression is as follows:
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer>
<HttpCompression> nodes are used to configure Static Compression and dynamic compression, and <urlCompression> nodes are used to switch http compression. By default, IIS 7.0 starts Static Compression and disables dynamic compression. in IIS 7.5 and later versions, static compression and dynamic compression are enabled by default. Set the doStaticCompression and doDynamicCompression attributes of the urlCompression node to true to enable compression. After the configuration is complete, restart IIS and go to the front-end for testing. We found that the KB js file was compressed to kb, and the effect was good.
Note that the configuration in ApplicationHost. config is the global configuration of IIS, which affects all websites. If you only want to enable http compression for a website, you can modify ApplicationHost. configure httpCompression under config, set the overrideModelDefault attribute to Allow, and Allow it to access the web. config. config ).
<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />