by Devin Yang

建立於: 6年前 ( 更新: 6年前 )

什麼是PageSpeed Insights?

PageSpeed Insights是一個Google提供分析工具,他會依據所謂的網站的最佳實踐(Web Best Practices)來分析及優化我們網站。
我可以用他提出的建議來進行網站的優化。

怎麼優化 ?

優化類型可分為整個的網頁結構及設定,包含了網頁圖檔的優化。
由於我目前使用的web hosting網站代管的主機商是Bluehost,而他使用的為Apache Web Server,
所以這裡分享我目使用的.htaccess設定方式,透過下方設定可以提升不少分數。(優化的部份)
.htaccess修改完請一定要確認是否可行,錯誤的設定會造成主機顯示500錯誤。
非常重點ExpiresDefault 至少要快取1個禮拜,這個讓我加了10分
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 week"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 week"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 week"
</IfModule>

結果

以下就是我使用PageSpped Insights在我瘋狂優化下的結果。
終於電腦版有95分了。

Tags: web-hosting

Devin Yang

文章內容無法一一說明,如果您有什麼不了解處,歡迎提問哦:)

No Comment

Post your comment

需要登入才可留言!