真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Apache的壓縮與緩存-----網(wǎng)頁(yè)優(yōu)化

一、Apache網(wǎng)頁(yè)的壓縮

定義:對(duì)apache服務(wù)器發(fā)布的網(wǎng)頁(yè)內(nèi)容進(jìn)行壓縮后再發(fā)送到客戶端的瀏覽器。減少了網(wǎng)絡(luò)傳輸用時(shí),也加快了網(wǎng)頁(yè)加載的速度。

在蟠龍等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計(jì)、網(wǎng)站制作 網(wǎng)站設(shè)計(jì)制作按需網(wǎng)站開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),全網(wǎng)整合營(yíng)銷推廣,外貿(mào)網(wǎng)站建設(shè),蟠龍網(wǎng)站建設(shè)費(fèi)用合理。

mod_gzip 模塊與mod_deflate 模塊

1.兩者均使用gzip壓縮算法,運(yùn)作原理類似
2.mod_deflate 壓縮速度略快,而mod_gzip 的壓縮比略高
3.mod_gzip 對(duì)服務(wù)器CPU的占用要高- -些
4.高流量的服務(wù)器,使用mod_deflate 可能會(huì)比mod_gzip 加載速
度更快

實(shí)驗(yàn)走起

1、代碼步驟如下:

[root@localhost ~]# mkdir /aaa
[root@localhost ~]# mount.cifs //192.168.10.12/rpm /aaa
Password for root@//192.168.10.12/rpm:  
[root@localhost ~]# cd /aaa
[root@localhost aaa]# ls
LAMP
[root@localhost aaa]# cd LAMP/
[root@localhost LAMP]# ls
apr-1.6.2.tar.gz                  error.png
apr-util-1.6.0.tar.gz             ha.jpg
awstats-7.6.tar.gz                httpd-2.4.29.tar.bz2
cronolog-1.6.2-14.el7.x86_64.rpm  MySQL-5.6.26.tar.gz
Discuz_X2.5_SC_UTF8.zip           php-5.6.11.tar.bz2
[root@localhost LAMP]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt
[root@localhost LAMP]# tar zxvf apr-1.6.2.tar.gz -C /opt/
[root@localhost LAMP]# tar zxvf apr-util-1.6.0.tar.gz -C /opt
[root@localhost LAMP]# cd /opt/
[root@localhost opt]# ls
apr-1.6.2  apr-util-1.6.0  httpd-2.4.29  rh
[root@localhost opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr
[root@localhost opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util
[root@localhost opt]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel expat-devel -y

[root@localhost opt]# cd httpd-2.4.29/
[root@localhost httpd-2.4.29]# ls
ABOUT_APACHE     CMakeLists.txt  INSTALL         NWGNUmakefile
acinclude.m4     config.layout   InstallBin.dsp  os
Apache-apr2.dsw  configure       LAYOUT          README
Apache.dsw       configure.in    libhttpd.dep    README.cmake
apache_probes.d  docs            libhttpd.dsp    README.platforms
ap.d             emacs-style     libhttpd.mak    ROADMAP
build            httpd.dep       LICENSE         server
BuildAll.dsp     httpd.dsp       Makefile.in     srclib
BuildBin.dsp     httpd.mak       Makefile.win    support
buildconf        httpd.spec      modules         test
CHANGES          include         NOTICE          VERSIONING
[root@localhost httpd-2.4.29]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
[root@localhost httpd-2.4.29]# make
[root@localhost httpd-2.4.29]# make install

[root@localhost httpd-2.4.29]# cd /usr/local/httpd/
[root@localhost httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@localhost httpd]# cd conf
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# vim httpd.conf 
[root@localhost conf]# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
[root@localhost conf]# vim /etc/httpd.conf 
/deflate,搜索這個(gè)關(guān)鍵詞    
LoadModule deflate_module modules/mod_deflate.so        //此行去除注釋

/headers,搜索這個(gè)關(guān)鍵詞
LoadModule headers_module modules/mod_headers.so        //此行需要去除注釋

/filter,搜索這個(gè)關(guān)鍵詞
LoadModule filter_module modules/mod_filter.so          //此行需要去除注釋

/Listen,搜索這個(gè)關(guān)鍵詞
Listen 192.168.234.172:80
#Listen 80

/ServerName,搜索這個(gè)關(guān)鍵詞
ServerName www.kgc.com:80

按大寫字母G到末行,按o轉(zhuǎn)下行插入

  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript text/ipg text/png
  DeflateCompressionLevel 9
  SetOutputFilter DEFLATE

//修改結(jié)束后按Esc退出,輸入:wq保存退出

[root@localhost conf]# /usr/local/httpd/bin/apachectl -t
Syntax OK
//驗(yàn)證語(yǔ)法是否正確

[root@localhost conf]# /usr/local/httpd/bin/apachectl start
[root@localhost conf]# netstat -ntap | grep 80
tcp       0      0 192.168.234.172:80       0.0.0.0:*        LISTEN      82881/httpd       [root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# cd ..
[root@localhost httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@localhost httpd]# cd htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# cat index.html 

It works!

[root@localhost htdocs]# cd /usr/local/httpd/bin/ [root@localhost bin]# ./apachectl -t -D DUMP_MODULES | grep "deflate" deflate_module (shared)

2、在/htdocs中添加進(jìn)圖片jpg,在index.html中輸入,客戶端通過(guò)IP訪問(wèn)瀏覽器,用fiddler進(jìn)行捕捉。

[root@localhost bin]# cd /aaa/LAMP
[root@localhost LAMP]# ls
apr-1.6.2.tar.gz                  ha.jpg
apr-util-1.6.0.tar.gz             httpd-2.4.29.tar.bz2
awstats-7.6.tar.gz                lf.jpg
cronolog-1.6.2-14.el7.x86_64.rpm  mysql-5.6.26.tar.gz
Discuz_X2.5_SC_UTF8.zip           php-5.6.11.tar.bz2
error.png
[root@localhost LAMP]# cp lf.jpg /usr/local/httpd/htdocs/       //把圖片復(fù)制到對(duì)應(yīng)的文件夾
[root@localhost LAMP]# cd /usr/local/httpd/
[root@localhost httpd]# cd htdocs/
[root@localhost htdocs]# ls
index.html  lf.jpg
[root@localhost htdocs]# vim index.html 

It works!

//格式做以上更改,在當(dāng)中插入圖片,按Esc退出,輸入:wq保存退出

Apache的壓縮與緩存-----網(wǎng)頁(yè)優(yōu)化
Apache的壓縮與緩存-----網(wǎng)頁(yè)優(yōu)化

結(jié)論:我們只要在網(wǎng)頁(yè)中嵌入了圖片或者視頻這類格式文件時(shí),網(wǎng)頁(yè)會(huì)通過(guò)打壓縮的方式再進(jìn)行傳輸,傳到對(duì)方的客戶端之后在進(jìn)行解壓縮的識(shí)別

二、Apache網(wǎng)頁(yè)的緩存

定義:將一部分經(jīng)常不會(huì)變動(dòng)或變動(dòng)較少的頁(yè)面緩存。下次瀏覽器訪問(wèn)這些頁(yè)面時(shí),不需要再次下載。提高了用戶的訪問(wèn)速度,降低客戶端的訪問(wèn)頻率。
基于之前已經(jīng)對(duì)apache的配置文件進(jìn)行了相對(duì)應(yīng)的設(shè)置,所以我們接下來(lái)只需要做如下更改:
1、代碼如下:

[root@localhost htdocs]# vim   /etc/httpd.conf
在末行按o轉(zhuǎn)下行插入以下內(nèi)容

  ExpiresActive   On
  ExpiresDefault   "access plus 50 seconds"

//修改完成后按Esc退出,輸入:wq保存退出

[root@localhost htdocs]# pwd
/usr/local/httpd/htdocs
[root@localhost htdocs]# cd  /usr/local/httpd/
[root@localhost httpd]# cd  bin/
[root@localhost bin]# ./apachectl  -t       //檢查語(yǔ)法
Syntax OK
[root@localhost bin]# ./apachectl  stop
[root@localhost bin]# ./apachectl  start

2、驗(yàn)證,進(jìn)行抓包測(cè)試
Apache的壓縮與緩存-----網(wǎng)頁(yè)優(yōu)化
Apache的壓縮與緩存-----網(wǎng)頁(yè)優(yōu)化


網(wǎng)頁(yè)名稱:Apache的壓縮與緩存-----網(wǎng)頁(yè)優(yōu)化
文章來(lái)源:http://weahome.cn/article/podpis.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部