在頁面中使用gzip可以有效的減低頁面的大小,加快網頁的下載速度。在lighttpd中對php頁面進行壓縮,需要兩個步驟:
1. 編輯 lighttpd.conf
將 “mod_compress” 設為啟用
接著找到
## compress module
在下面加入
compress.cache-dir = “/var/tmp/lighttpd/cache/”
compress.filetype = (”text/plain”, “text/html”, “text/css”, “text/javascript”)
做完上面的動作后,
基本上 .txt .html .css .js 的文件都會被Gzip壓縮了。但php此時還沒有壓縮
對于動態的php文件,還需要在php.ini中做相關設置,否則.php頁面還是不使用壓縮模式
2. 編輯 php.ini
修改
zlib.output_compression = On
zlib.output_handler = On
重新啟動Lighttpd。
這樣php也壓縮了
posted on 2011-06-22 23:25
Alpha 閱讀(800)
評論(0) 編輯 收藏 所屬分類:
Linux Nginx