<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gzip &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/gzip/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Fri, 11 Mar 2022 06:10:36 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>gzip &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>網頁壓縮亂碼 &#8211; Lighttpd gzip php, js, css, html, plain</title>
		<link>https://noter.tw/1748/%e7%b6%b2%e9%a0%81%e5%a3%93%e7%b8%ae%e4%ba%82%e7%a2%bc-lighttpd-gzip-php-js-css-html-plain/</link>
					<comments>https://noter.tw/1748/%e7%b6%b2%e9%a0%81%e5%a3%93%e7%b8%ae%e4%ba%82%e7%a2%bc-lighttpd-gzip-php-js-css-html-plain/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Thu, 29 Dec 2011 15:59:46 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[亂碼]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[zlib.output_compression]]></category>
		<guid isPermaLink="false">http://wazai.net/1748/%e7%b6%b2%e9%a0%81%e5%a3%93%e7%b8%ae%e4%ba%82%e7%a2%bc-lighttpd-gzip-php-js-css-html-plain</guid>

					<description><![CDATA[<p>蛙齋速度慢的原因雖然有很大部份是在VPS的速度，在沒有經費可以提高VPS花費的情況下，只好從網站的優化開始做起，小蛙在Google網站管理員工具中看到一個「網站效能」的選項，裡面提到了可以安裝Fire&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1748/%e7%b6%b2%e9%a0%81%e5%a3%93%e7%b8%ae%e4%ba%82%e7%a2%bc-lighttpd-gzip-php-js-css-html-plain/" data-wpel-link="internal">網頁壓縮亂碼 &#8211; Lighttpd gzip php, js, css, html, plain</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>蛙齋速度慢的原因雖然有很大部份是在VPS的速度，在沒有經費可以提高VPS花費的情況下，只好從網站的優化開始做起，小蛙在<a href="https://www.google.com/webmasters/" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">Google網站管理員工具<span class="wpel-icon wpel-image wpel-icon-6"></span></a>中看到一個「網站效能」的選項，裡面提到了可以安裝Firefox的plugin來測試網站的效能，小蛙點了安裝之後，瀏覽網頁的時候按下<span style="color: #ff0000;"><strong>F12</strong></span>就可以看到Firefox下面的Firebug最右邊多出了一欄「<a href="http://code.google.com/intl/zh-TW/speed/page-speed/download.html" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">Page Speed<span class="wpel-icon wpel-image wpel-icon-6"></span></a>」。<br />
<span id="more-1748"></span><br />
測試之後的結果發現在「<strong><span style="color: #ff0000;">使用瀏覽器快取</span></strong>」跟「<strong><span style="color: #ff0000;">啟用壓縮功能</span></strong>」的部份是黃色驚嘆號，也就是還可以加強的部分。小蛙記得前一陣子就有啟用lighttpd的compress功能，在firebug下面也可以看到Content-Encoding: gzip了，為什麼還會在「啟用壓縮功能」的這個項目不符合呢？Google了一下發現lighttpd中設定的只有下面這些選項，沒有包含到PHP頁面。</p>
<pre>"text/plain", "text/html", "application/x-javascript", "text/css", "application/javascript", "text/javascript", "application/x-javascript"</pre>
<p>這篇文章小蛙記錄一下整個設定的流程，主要分成兩個部份，分別是lighttpd.conf以及php.ini。(參考資料：<a href="http://ching119.pixnet.net/blog/post/59675615-%E3%80%90%EF%BC%AC%E3%80%91%E8%A8%AD%E5%AE%9Agzip---lighttpd-%26-php" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">【Ｌ】設定Gzip &#8211; Lighttpd &amp; PHP @ Ching Wei : This is My Life &#8211; 工作、攝影、旅遊<span class="wpel-icon wpel-image wpel-icon-6"></span></a>)</p>
<h2><span style="color: #ff0000;">/etc/lighttpd/lighttpd.conf</span></h2>
<ol>
<li>首先在<span style="color: #ff0000;"><strong>server.modules</strong></span>的部份要打開<span style="color: #ff0000;"><strong>&#8220;mod_compress&#8221;</strong></span>的選項，把前面的「#」拿掉就可以了。</li>
<li>設定快取儲存資料夾。
<pre>compress.cache-dir = "/var/cache/lighttpd/compress/"</pre>
</li>
<li>設定要壓縮的類型。
<pre>compress.filetype = ("text/plain", "text/html", "application/x-javascript", "text/css", "application/javascript", "text/javascript", "application/x-javascript")</pre>
</li>
<li>重啟lighttpd，就可以透過firebug在剛剛設定的像css, javascript … 等檔案類型中看到「Accept-Encoding: gzip」的字樣。</li>
</ol>
<h2><span style="color: #ff0000;">/etc/php5/cgi/php.ini</span></h2>
<ol>
<li>這個php.ini的檔案可能會在不同路徑下，找不到的話可以下「locate php.ini」找找看，如果還是找不到可以在下locate之前先下「updatedb」的指令更新。</li>
<li>找到「<span style="color: #ff0000;"><strong>;zlib.output_compression = On</strong></span>」的字樣，把前面的「<span style="color: #ff0000;"><strong>;</strong></span>」拿掉。</li>
<li>存檔離開後，重新啟動lighttpd。</li>
</ol>
<p>透過以上設定就可以讓lighttpd跟php都使用gzip壓縮功能，但是小蛙設定完之後卻發現IE跟Chrome開啟頁面的時候是呈現亂碼的狀態，小蛙百思不得其解，Google了一會兒，<a href="http://ching119.pixnet.net/blog/post/59676021-%E3%80%90%E7%A8%8B%E5%BC%8F%E3%80%91php---gzencode-%E5%BE%8C%E8%AE%8A%E4%BA%82%E7%A2%BC-!!" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">【程式】PHP &#8211; gzencode 後變亂碼 !! @ Ching Wei : This is My Life &#8211; 工作、攝影、旅遊<span class="wpel-icon wpel-image wpel-icon-6"></span></a> 和 <a href="http://wenwen.soso.com/z/q202202824.htm" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">PHP静态页面GZIP压缩乱码问题 @ SOSO問問<span class="wpel-icon wpel-image wpel-icon-6"></span></a> 有提到會變成亂碼是做了兩次gzip造成的，小蛙改了半天，卻始終都還是亂碼(不同的theme可能會有不同情況)。<br />
之後小蛙把矛頭指向Hyper Cache這個套件(因為發現這個套件下面有很多跟gzip相關的字眼)，查了一下發現，原來在安裝完Hyper Cache的時候，預設狀態中「Enable compression」是開啟的，所以造成壓縮兩次的情況，只要把Enable compression關掉就可以了。</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1748/%e7%b6%b2%e9%a0%81%e5%a3%93%e7%b8%ae%e4%ba%82%e7%a2%bc-lighttpd-gzip-php-js-css-html-plain/" data-wpel-link="internal">網頁壓縮亂碼 &#8211; Lighttpd gzip php, js, css, html, plain</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/1748/%e7%b6%b2%e9%a0%81%e5%a3%93%e7%b8%ae%e4%ba%82%e7%a2%bc-lighttpd-gzip-php-js-css-html-plain/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
