在Debian上設置Apache壓縮傳輸,需啟用mod_deflate模塊并配置相關參數,具體步驟如下:
sudo a2enmod deflate啟用mod_deflate模塊,若模塊已啟用則無需操作。/etc/apache2/apache2.conf或/etc/apache2/sites-available/your-site.conf文件,在<IfModule mod_deflate.c>和</IfModule>標簽間添加配置,如AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript,還可設置壓縮級別DeflateCompressionLevel 6(范圍1-9,6為默認)。sudo systemctl restart apache2重啟Apache服務。Content-Encoding字段,若為gzip,則壓縮已生效。