老妇女性较大毛片,互换-完美的邻居HD中文,久久久久久精品免费无码无,野花香在线视频免费观看第一集

如何設置靜態(tài)內容緩存時(shí)間

時(shí)間:2014-06-21 來(lái)源:天津文率科技有限公司

其實(shí)設置靜態(tài)內容緩存時(shí)間就是讓網(wǎng)頁(yè)里的圖片還有js、css這些資源、包括頁(yè)面緩存到本地而不是每次都去服務(wù)器請求資源,這樣做可以減輕服務(wù)器的帶寬壓力和使網(wǎng)頁(yè)打開(kāi)速度加快,這樣以來(lái)用戶(hù)體驗就會(huì )好了一些,對seo是有好處的。

那么如何來(lái)設置緩存時(shí)間呢?下面我就以apache為例吧,因為我們的官網(wǎng)用的是php+apache的,所以小韓就拿apache來(lái)說(shuō)了

本文關(guān)鍵詞:gzip, cache-expire

用.htaccess設置網(wǎng)頁(yè)/圖片/js/css文件內容緩存

開(kāi)啟gzip的方法:

1、 http.conf下
將#去掉
LoadModule deflate_module modules/mod_deflate.so
添加如下設置:
<IfModule mod_deflate.c>
<Location />
#Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.59
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html force-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# 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
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

#DeflateFilterNote ratio ratio_info
#LogFormat ‘”%v %h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”” (%{ratio}n)’ deflate
#CustomLog logs/deflate_log deflate
</Location>
保存退出。重新啟動(dòng)apache就生效了

2 開(kāi)啟cache-expire

第1步
LoadModule expires_module modules/mod_expires.so
LoadModule expires_module modules/mod_headers.so
在httpd.conf中,找到上面的代碼,然后將前面的#去掉

第2步
在httpd.conf中加入以下代碼,可以加到任何空白地方,不了解apache的朋友,如果擔心加錯地方,就放到http.conf文件的最后一行

<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/gif A2592000

ExpiresByType image/jpeg A2592000

ExpiresByType image/png A2592000

ExpiresByType image/x-icon A2592000

ExpiresByType application/x-javascript A604800

ExpiresByType text/css A604800

</IfModule>
如果apache無(wú)法啟動(dòng)了,檢查下是不是權限受了影響,因為如果訪(fǎng)問(wèn)權限設置的不對的話(huà)會(huì )報錯,具體可以查看apche的日志,然后百度去找問(wèn)題根源了。

在開(kāi)發(fā)過(guò)程中會(huì )有各種想不到的問(wèn)題出現,這時(shí)我建議大家多百度和谷歌一下。

好啦

不早啦,明天我們天津網(wǎng)站建設公司-文率科技來(lái)講講如何用壓縮js和css代碼。

更多網(wǎng)站建設方面的知識請關(guān)注我們的官網(wǎng) www.179fanli.com。


聯(lián)絡(luò )方式:

中國 · 天津市河西區南京路35號亞太大廈1403室
電話(huà):15620613686
郵編:300220

樟树市| 威海市| 顺义区| 启东市| 昌图县| 昌宁县| 南川市| 南丰县| 湾仔区| 许昌县| 兰坪| 阿拉善右旗| 灵台县| 徐州市| 海丰县| 平乡县| 霍山县| 正阳县| 女性| 伊春市| 抚州市| 舒城县| 广昌县| 长乐市| 涟水县| 泰州市| 秦皇岛市| 留坝县| 桃江县| 偏关县| 龙里县| 肥东县| 庆阳市| 万安县| 阿克| 崇义县| 雷波县| 鲜城| 九江市| 原阳县| 兴文县|