內容簡介
這個外掛可以在你的 Apache 網頁伺服器上啟用瀏覽器快取和 GZIP 壓縮。
啟用瀏覽器快取功能可以告訴瀏覽器哪些檔案通常會變更,例如每個月、每週等等。這可以讓你的網站加速,因為瀏覽器只會在指定的時間後重新向伺服器發送請求。PageSpeed 是 Google 的排名因素之一,因此擁有快速的網站非常重要。
啟用瀏覽器快取的方法有很多種,而這個外掛使用 Expires。以下的程式碼將被添加到你的 .htaccess 檔案中:
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/xhtml-xml "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
啟用 GZIP 壓縮功能可以在發送到客戶端之前壓縮你的檔案。這也可以讓你的網站加速。以下的程式碼將被添加到你的 .htaccess 檔案中:
Header append Vary User-Agent env=!dont-vary
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
DEFLATE 標籤也可以用來啟用透過附檔名的方式進行 GZIP 壓縮。以下程式碼會啟用透過附檔名進行 GZIP 壓縮:
AddOutputFilter DEFLATE js css htm html xml
外掛標籤
開發者團隊
原文外掛簡介
With this Plugin you can activate Browser Caching and GZIP Compression on your Apache Webserver.
With Browser Caching you can tell Browsers when your files usually change, e.g. every month, every week, etc. This will speed up your website because Browser will only make requests to your Server after the declared time. PageSpeed is a Google Ranking Factor so it is important to have a fast website.
There a several ways to enable Browser Caching. This Plugin uses Expires. The following code will be added to your .htaccess file:
ExpiresActive On
ExpiresByType text/css “access plus 1 month”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType text/html “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
ExpiresByType application/xhtml-xml “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”
With GZIP Compression your files will be compressed before they get sent to the client. This also makes your Website faster. The following code will be added to your .htaccess file:
Header append Vary User-Agent env=!dont-vary
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
