網站 Yslow 優化

1、Compress components with gzip 方法

默認認並沒有開啓gzip功能。需要修改apache的配置文件進行開啓。

開啓方法如下:

1. httpd.conf中打開deflate_Module和headers_Module模塊(找到包含有deflate_Module和headers_Module去掉前面的“#”號 window下面的方法。)

2. httpd.conf最後面添加:

<IfModule deflate_module>
    SetOutputFilter DEFLATE
    # 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
</IfModule>
2、
Add Expires headers
在網站的根目錄找到.htaccess文件打開並添加以下代碼
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A3600
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A2592000
ExpiresByType video/x-flv A2592000
ExpiresByType application/pdf A2592000
ExpiresByType text/html A600
ExpiresByType image/x-icon A2592000
ExpiresByType application/javascript A604800
ExpiresByType text/css A604800
</IfModule>

3、Configure entity tags (ETags)

在網站的根目錄找到.htaccess文件打開並添加以下代碼

FileETag none



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章