<?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>A Tempest of Thoughts &#187; lighttpd</title>
	<atom:link href="http://tempe.st/category/lighttpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://tempe.st</link>
	<description>aka blog.to_int(:inig)</description>
	<lastBuildDate>Thu, 07 Apr 2011 08:24:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Lightning speed WordPress with Lighttpd and Supercache, part II</title>
		<link>http://tempe.st/2008/05/lightning-speed-wordpress-with-lighttpd-and-supercache-part-ii/</link>
		<comments>http://tempe.st/2008/05/lightning-speed-wordpress-with-lighttpd-and-supercache-part-ii/#comments</comments>
		<pubDate>Mon, 05 May 2008 09:13:44 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[Lua]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[wp-supercache]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=210</guid>
		<description><![CDATA[There was an error in the code I wrote for my previous post about lighttpd and wp-supercache. If you kept GZip disabled in you wp-supercache configuration, and your browser sent an Accepts gzip header, lightpress would serve the dynamic page (instead of the cached html page). I did some refactoring and testing, and here&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[	<p>There was an error in the code I wrote for my previous post about <a href="http://tempe.st/2008/04/lighttpd-and-wp-supercache-now-you-can/">lighttpd and wp-supercache</a>. If you kept GZip disabled in you wp-supercache configuration, and your browser sent an Accepts gzip header, lightpress would serve the dynamic page (instead of the cached html page). </p>
	<p>I did some refactoring and testing, and here&#8217;s the current version of rewrite.lua. This one will serve the correct gzipped or text content, while solving another bug with urls ending in &#8221;/&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;"><span style="color: #b1b100;">function</span> serve_html<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>lighty.stat<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
    lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> cached_page
    <span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Serving cached page: &quot;</span> .. cached_page<span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">true</span>
  <span style="color: #b1b100;">else</span>
    <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">false</span>
  <span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">end</span>
&nbsp;
<span style="color: #b1b100;">function</span> serve_gzip<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>lighty.stat<span style="color: #66cc66;">&#40;</span>cached_page .. <span style="color: #ff0000;">&quot;.gz&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
    lighty.header<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Content-Encoding&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;gzip&quot;</span>
    lighty.header<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&quot;</span>
    lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> cached_page .. <span style="color: #ff0000;">&quot;.gz&quot;</span>
    <span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Serving gzipped page: &quot;</span> .. cached_page .. <span style="color: #ff0000;">&quot;.gz&quot;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">true</span>
  <span style="color: #b1b100;">else</span>
    <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">false</span>
  <span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">end</span>
&nbsp;
attr <span style="color: #66cc66;">=</span> lighty.stat<span style="color: #66cc66;">&#40;</span>lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> attr<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
  lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;/index.php&quot;</span>
  lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.rel-path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.path&quot;</span><span style="color: #66cc66;">&#93;</span>
  lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.doc-root&quot;</span><span style="color: #66cc66;">&#93;</span> .. lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.rel-path&quot;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
  query_condition <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span>lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.query&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.query&quot;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">&quot;.*s=.*&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  user_cookie <span style="color: #66cc66;">=</span> lighty.request<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Cookie&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;no_cookie_here&quot;</span>
  cookie_condition <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>user_cookie, <span style="color: #ff0000;">&quot;.*comment_author.*&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>user_cookie, <span style="color: #ff0000;">&quot;.*wordpress.*&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>user_cookie, <span style="color: #ff0000;">&quot;.*wp-postpass_.*&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>query_condition <span style="color: #b1b100;">and</span> cookie_condition<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
    accept_encoding <span style="color: #66cc66;">=</span> lighty.request<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Accept-Encoding&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;no_acceptance&quot;</span>
    cached_page <span style="color: #66cc66;">=</span> lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.doc-root&quot;</span><span style="color: #66cc66;">&#93;</span> .. <span style="color: #ff0000;">&quot;/wp-content/cache/supercache/&quot;</span> .. lighty.request<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #66cc66;">&#93;</span> .. lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;request.uri&quot;</span><span style="color: #66cc66;">&#93;</span> .. <span style="color: #ff0000;">&quot;/index.html&quot;</span>
    cached_page <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">string.gsub</span><span style="color: #66cc66;">&#40;</span>cached_page, <span style="color: #ff0000;">&quot;//&quot;</span>, <span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>accept_encoding, <span style="color: #ff0000;">&quot;gzip&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
      <span style="color: #b1b100;">if</span> <span style="color: #b1b100;">not</span> serve_gzip<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span> serve_html<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">end</span>
    <span style="color: #b1b100;">else</span>
      serve_html<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span>
    <span style="color: #b1b100;">end</span>
  <span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">end</span></pre></div></div>



 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/05/lightning-speed-wordpress-with-lighttpd-and-supercache-part-ii/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Lighttpd and WP-Supercache? Now you can!</title>
		<link>http://tempe.st/2008/04/lighttpd-and-wp-supercache-now-you-can/</link>
		<comments>http://tempe.st/2008/04/lighttpd-and-wp-supercache-now-you-can/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 13:53:45 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[Lua]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp-cache]]></category>
		<category><![CDATA[wp-supercache]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=202</guid>
		<description><![CDATA[Update: there are some bugs with this code. You can find the newest (and best) version here It&#8217;s often said that if you can&#8217;t find something in Google it doesn&#8217;t exist, and when I couldn&#8217;t find a way to serve WP-Supercached pages via Lighttpd I was pretty sure no one had ever published on the [...]]]></description>
			<content:encoded><![CDATA[	<p><strong>Update:</strong> there are some bugs with this code. You can find the newest (and best) version <a href="http://tempe.st/2008/05/lightning-speed-wordpress-with-lighttpd-and-supercache-part-ii/">here</a></p>
	<p>It&#8217;s often said that if you can&#8217;t find something in Google it doesn&#8217;t exist, and when I couldn&#8217;t find a way to serve <a href="http://ocaoimh.ie/wp-super-cache/">WP-Supercache</a>d pages via Lighttpd I was pretty sure no one had ever published on the net a solution to my problem.</p>
	<p>Nice permalinks were easy to fix, thanks to <a href="http://sudhaker.com/2008/04/wordpress-permalinks-lighttpd/">this tutorial</a>, but cache was a no-go: the lighttpd wiki and the wordpress forums had no info, so I had to cook a solution for myself. </p>
	<p>It was easier than I thought though:</p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- rewrite.lua, in your WP_ROOT</span>
attr <span style="color: #66cc66;">=</span> lighty.stat<span style="color: #66cc66;">&#40;</span>lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">not</span> attr<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
  lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;/index.php&quot;</span>
  lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.rel-path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.path&quot;</span><span style="color: #66cc66;">&#93;</span>
  lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.doc-root&quot;</span><span style="color: #66cc66;">&#93;</span> .. lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.rel-path&quot;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
  query_condition <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span>lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.query&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;uri.query&quot;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">&quot;.*s=.*&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  user_cookie <span style="color: #66cc66;">=</span> lighty.request<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Cookie&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;no_cookie_here&quot;</span>
  cookie_condition <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>user_cookie, <span style="color: #ff0000;">&quot;.*comment_author.*&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>user_cookie, <span style="color: #ff0000;">&quot;.*wordpress.*&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>user_cookie, <span style="color: #ff0000;">&quot;.*wp-postpass_.*&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>query_condition <span style="color: #b1b100;">and</span> cookie_condition<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
    accept_encoding <span style="color: #66cc66;">=</span> lighty.request<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Accept-Encoding&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;no_acceptance&quot;</span>
    cached_page <span style="color: #66cc66;">=</span> lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.doc-root&quot;</span><span style="color: #66cc66;">&#93;</span> .. <span style="color: #ff0000;">&quot;/wp-content/cache/supercache/&quot;</span> .. lighty.request<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Host&quot;</span><span style="color: #66cc66;">&#93;</span> .. lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;request.uri&quot;</span><span style="color: #66cc66;">&#93;</span> .. <span style="color: #ff0000;">&quot;/index.html&quot;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">string.find</span><span style="color: #66cc66;">&#40;</span>accept_encoding, <span style="color: #ff0000;">&quot;gzip&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>lighty.stat<span style="color: #66cc66;">&#40;</span>cached_page .. <span style="color: #ff0000;">&quot;.gz&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
        lighty.header<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Content-Encoding&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;gzip&quot;</span>
        lighty.header<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&quot;</span>
        lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> cached_page
      <span style="color: #b1b100;">end</span>
    <span style="color: #b1b100;">else</span>
      <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>lighty.stat<span style="color: #66cc66;">&#40;</span>cached_page<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
        lighty.env<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;physical.path&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> cached_page
      <span style="color: #b1b100;">end</span>
    <span style="color: #b1b100;">end</span>
  <span style="color: #b1b100;">end</span>
<span style="color: #b1b100;">end</span></pre></div></div>

	<p>This rewrite.lua will serve compressed cached pages to those who accept gzip and plain html to those who prefer not to get gzip, while retaining the nice permalinks.</p>


 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/04/lighttpd-and-wp-supercache-now-you-can/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

