影音先锋Av网址,国产福利精品一区,亚洲AV动漫另类卡通精品日韩,日本三ji片区电影,轻点疼快点太深了视频,含紧一点H边做边走女女视频

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

時間:2014-06-21 來源:天津文率科技有限公司

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

那么如何來設置緩存時間呢?下面我就以apache為例吧,因為我們的官網用的是php+apache的,所以小韓就拿apache來說了

本文關鍵詞:gzipcache-expire

用.htaccess設置網頁/圖片/js/css文件內容緩存

開啟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>
保存退出。重新啟動apache就生效了

2 開啟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無法啟動了,檢查下是不是權限受了影響,因為如果訪問權限設置的不對的話會報錯,具體可以查看apche的日志,然后百度去找問題根源了。

在開發(fā)過程中會有各種想不到的問題出現(xiàn),這時我建議大家多百度和谷歌一下。

好啦

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

更多網站建設方面的知識請關注我們的官網 www.milestonesys.cn。


聯(lián)絡方式:

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

彰化县| 桦南县| 房产| 浙江省| 遵义县| 班玛县| 吉首市| 西峡县| 博爱县| 定边县| 蒙阴县| 凉城县| 乌鲁木齐县| 元朗区| 出国| 兖州市| 河北省| 嘉善县| 千阳县| 三门峡市| 翁源县| 荃湾区| 正定县| 泰来县| 滦南县| 阿勒泰市| 上高县| 呼玛县| 毕节市| 宜阳县| 合作市| 慈利县| 云梦县| 刚察县| 黑山县| 榆中县| 资中县| 枞阳县| 百色市| 巴彦淖尔市| 百色市|