Website access optimization (2): Enable gzip compression and apachegzip on the apache server

Source: Internet
Author: User
Tags piwik

Website access optimization (2): Enable gzip compression and apachegzip on the apache server
Yesterday, the bandwidth was upgraded from 1 Mbps to 2 Mbps. After using the cdn jquery version, the Website access speed was increased from 5 s on average (the Cache Usage was approximately 2.8 s when cache is disabled) dropped to 2.8s.

Continue optimization today.

Step 2:
The image is compressed, and the banner of more than 70 KB uses a larger image to compress it to about 50 kb. The quality of images has dropped a little, and no money can even be used for HD images. Therefore, you still have to have money to make money.

Step 2:
Js compression.

Yesterday, we also used the js/css compressors downloaded from the Internet. during deployment, we used compressed versions. The speed has not been significantly improved, probably because js and css are few and both are relatively small.

In the evening, I checked my website access with my Baidu Webmaster. On average, it was 3 seconds slower than my local (Hubei-Wuhan-20 mb bandwidth) 2.8s.

One diagnosis suggestion is to use gzip compression.

So today, I tried Apache to enable gzip compression.
Step 2: Find and open the httpd. conf file in the apache/conf directory.
Step 2: Enable the deflate_Module and headers_Module modules in httpd. conf. Remove the following two sentences:

LoadModule deflate_module modules/mod_deflate.so

LoadModule headers_module modules/mod_headers.so

Step 2: Add the following code to the bottom of the httpd. conf file to configure the file to be compressed:

<IfModule deflate_module>
SetOutputFilter DEFLATE
# Don't compress images and other
SetEnvIfNoCase Request_URI .(? : Gif | jpe? G | png) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Pdf | doc) $ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
Step 2: restart the apache server
Check the syntax first to see if it is correct.
/Etc/init. d/httpd-t
/Etc/init. d/httpd restart
Step 2: Use a tool to re-check whether gzip compression is enabled. Take into account the specific gzip detection tool access address of the relevant advertising detection mechanism can be found in the search engine.
Http://tool.chinaz.com/Gzips/
Enter your domain name.

In addition, you can also use Chrome to view.

  1. Content-Encoding: gzip
  2. After GZIP compression is started, Response Headers will display the above line.

Four questions:
1. How much is the difference between enabling gzip compression in Apache and manually compressing JS/CSS?
Of course, gzip works well.
2. Apache version issues.
Local Apache is 2.4.9, and online Apache is 2.2.
An error was reported in the local device. I searched the internet for "AddOutputFilterByType"
Apache AddOutputFilterByType is deprecated. How to rewrite using mod_filter?
There is a saying on the Internet that 2.4 is no longer supported, but later versions of 2.2 succeeded.

2.4 AddOutputFilterByType configuration, refer to the following: http://stackoverflow.com/questions/5230202/apache-addoutputfilterbytype-is-deprecated-how-to-rewrite-using-mod-filter
Apache on the local machine 2.4 fails.

3. In. htaccess, gzip compression is not successfully configured.
4. The statistical program piwik. js has a certain impact on the response time.
Piwik is occasionally unstable, especially when the bandwidth is 1 Mbps.
----------------------------------
After GZIP compression is enabled, the average access time of the home page is reduced to 1.8 s.
1.82 s (load: 1.28, DOMContentLoaded: 397 ms)

When caching is enabled, 2nd accesses are performed:
1.00 s (load: 469 ms, DOMContentLoaded: 352 ms)
----------------------------------
Upgrade the bandwidth to 3 Mbps, with the average access speed: http ://

Disable browser cache: 1.69 s (load: 1.16 s, DOMContentLoaded: 415 ms)

Start the browser cache: 1.18 s (load: 640 ms, DOMContentLoaded: 349 ms)

----------------------------------
ThinkPHP cache: if it is in debug mode, it will take about one second.
----------------------------------
Conclusion: After the bandwidth is upgraded from 1 Mbps to 3 Mbps, images are compressed with Fireworks, Gzip compression of Apache is enabled, and jquery of cdn version is used,
The average access speed ranges from 5s to 1.5 s.

Of course, Thinkphp uses the cache, And the browser does not disable the cache.
It can be opened within 2 seconds. You can accept it.

Wuhan nine days bird technology: Http://jiutianniao.comhttp: // jiutianniao.com.
Welcome to visit the official website and try to get the response speed.

----------------------------------
References:
Http://jingyan.baidu.com/article/db55b609a7bc234ba20a2f7e.html
Http://stackoverflow.com/questions/5230202/apache-addoutputfilterbytype-is-deprecated-how-to-rewrite-using-mod-filter

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.