PageSpeed Insights

PageSpeed Modules

  • 提供 Apache 與 Nginx 二種目前最受歡迎的 HTTP Server,另外下載時還要注意機器是 32-bit/64-bit

Installation

  • ubuntu 可以透過 deb 快速安裝,之後重啟 HTTP Server 預設就會啟用;以下以 Apache Debian/Ubuntu 64-bit 為範例
# 下載 deb
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_amd64.deb

# 安裝
sudo dpkg -i mod-pagespeed-stable*.deb

# 重啟 apache2
sudo service apache2 restart

其他可以提高分數的方法

清除前幾行內容中的禁止轉譯 JavaScript 和 CSS

  • 移動 JavaScript 的位置從 head 到 body
  • 要注意一些 lib(e.g. jQuery) 還是要在有引用到的 JavaScript 之前

使用瀏覽器快取功能

sudo a2enmod expires
sudo service apache2 restart
  • 修改網站的 .htaccess,加入 mod_expires 設定

    ExpiresActive on
    ExpiresDefault A86400
    ExpiresByType image/x-icon A7776000
    ExpiresByType application/x-javascript A604800
    ExpiresByType application/javascript A604800
    ExpiresByType text/css A604800
    ExpiresByType image/gif A2592000
    ExpiresByType image/png A2592000
    ExpiresByType image/jpeg A2592000
    ExpiresByType text/plain A86400
    ExpiresByType application/x-shockwave-flash A2592000
    ExpiresByType video/x-flv A2592000
    ExpiresByType application/pdf A2592000
    ExpiresByType text/html A3600
    ExpiresByType application/x-font-woffl A7776000
    ExpiresByType application/vnd.ms-fontobject A7776000
    ExpiresByType image/svg+xml A7776000
文章標籤

danielhuang030 發表在 痞客邦 留言(0) 人氣()