japanese少妇高潮潮喷 -精品国产AV一区二区三区-麻豆av一区二区三区久久-国产精品无码专区

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

發(fā)布時間:2025-03-02 點擊:26
其實設置靜態(tài)內容緩存時間就是讓網(wǎng)頁里的圖片還有js、css這些資源、包括頁面緩存到本地而不是每次都去服務器請求資源,這樣做可以減輕服務器的帶寬壓力和使網(wǎng)頁打開速度加快,這樣以來用戶體驗就會好了一些,對seo是有好處的。
那么如何來設置緩存時間呢?下面我就以apache為例吧,因為我們的官網(wǎng)用的是php+apache的,所以小韓就拿apache來說了
本文關鍵詞:gzip, cache-expire
用.htaccess設置網(wǎng)頁/圖片/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),這時我建議大家多百度和谷歌一下。
好啦



如何建設品牌創(chuàng)意網(wǎng)站
域名系統(tǒng)CDN是什么?利用好CDN我們可以做哪些事情
seo優(yōu)化之文章更新四大基礎要點
在Dreamweaver中如何建立站點的步驟有哪些
重慶網(wǎng)站建設的基本步驟及流程
獨立B2C商城優(yōu)勢 企業(yè)商城應該這樣建!
網(wǎng)站設計中配色的原則
網(wǎng)站優(yōu)化關鍵詞的包裝技巧