Two steps significantly increase website access speed

Source: Internet
Author: User
Tags metabase

Step 1: Set the HTTP header to cache static files (JS, CSS, HTML, and images), greatly improving the page access speed. The settings are as follows (the following settings are for IIS6, because other things have never been used, tips ):
1. IIS-> website-> select a site-> right-click-> Properties
2. Select HTTP header on the tab-> enable content expiration-> expire after this time period. The default value is 1 day.
Principle: using sniffer, we can see that when a user first requests this page, he will automatically process the HTTP header of the static file, and add cache-control: Max-age, when the user requests this page again for the second time, the browser will first determine whether the local file has expired, as shown in

If it does not expire, it will be read from the local machine directly without sending any requests to the server. This method is only applicable to static files, such as JS, CSS, HTML, and images. If you press F5 to refresh the page, the browser ignores the local cached files.
Advantage: greatly reducing the number of requests and bandwidth
Disadvantage: If the Server File is updated, the local file will not be updated unless you press F5 to refresh the page.
Solution: Use version control when updating static file JS, CSS, and images, for example, base. after the JS is changed, it is changed to base1.0.js. However, we need to change all the previous references to this file. Or you can set the cache time to a little smaller, 1 or 2 days is more suitable

 

Step 2: Use gzip to compress HTTP streams, which can greatly reduce the page size and bandwidth. The operations are as follows:
1. IIS-> website-> properties-> Service
2. Select HTTP compression on the tab-> "Zip application" Program Files "and" compressed static files ", set" temporary directory "and" maximum temporary directory limit "as needed"
3. Choose IIS> Web Service Extension> Add a new Web Service extension.
4. In the "new web service extension" box, enter the extension "HTTP compression" and add the "required file" to c: \ windows \ system32 \ inetsrv \ gzip. DLL, select "set extension status to allow"
5. Use a text editor to Open c: \ windows \ system32 \ inetsrv \ metabase. XML (backup is recommended) and find location = "/lm/w3svc/filters/compression/gzip"
6. To Compress dynamic files, set hcdodynamiccompression to "true" and add the dynamic file suffix to hcscriptfileextensions, such as aspx, shtml, and ASP.
7. To Compress static files, set hcdostaticcompression and hcdoondemandcompression to "true", and add the suffix of the static files to be compressed in hcfileextensions, such as HTML, JS, CSS, XML, etc.
8. hcdynamiccompressionlevel and hcondemandcomplevel indicate the required compression ratio. The smaller the number, the lower the compression ratio, and the smaller the performance consumption. The larger the number, the higher the compression ratio, and the greater the performance consumption. The optimum cost-performance ratio is 9.
9. Open start> Administrative Tools> service, stop "IIS Admin Service", and save the metabase. xml file. If it is not stopped, it cannot be saved.
10. Restart IIS
Principle: After the IIS compression function is enabled on the IIS server, before the IIS server sends the page content to the browser, It compresses the content on the server and then sends the compressed data, after the browser receives the data, it automatically decompress it and then displays it. Because the data transmitted over the network is compressed, the page content can be transmitted to the browser faster, improving the page browsing speed.
Advantage: reduces bandwidth consumption and increases access speed
Disadvantages:
1. There will be a certain amount of CPU resource consumption, but this consumption has little impact on the current CPU
2. gzip-enabled browsers are required. However, most browsers currently support gzip, so you can use it with confidence.
3. gzip compression for images, compressed files, and other files that cannot be further compressed will not only reduce bandwidth, but will increase server load and affect response speed
Note: If the server downloads an object by using the ASPX page to output the HTTP stream, if the aspx dynamic page is compressed, the gzip compression is also equivalent to compressing the compressed file, this will seriously affect the response speed during the download, that is, you may have clicked the download file connection. It will take 1, 2 minutes or even longer for you to download the file in a save file box.

 

After the above two steps, the access speed of our website is greatly improved. It takes 30 seconds or more to open a page, and now it takes less than 10 seconds.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.