Posts Tagged ‘Wordpress’
Wordpress + Lighttpd + WP-Supercache + Mobile Support
Posted by Giovanni Intini | Filed under Lua, Wordpress
Last year I made some work on lighttpd support for wp-supercache. It instantly became very popular and basically anyone running wordpress on lighttpd uses it, even if it lacks support for wp-supercache newest features.
The amazing Jean Pierre Wenzel has recently released an updated version that adds a much needed mobile support.
You can check it out here.
Thanks Jean Pierre!
Lightning speed Wordpress with Lighttpd and Supercache, part II
Posted by Giovanni Intini | Filed under Lua, Wordpress, lighttpd
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’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 ”/”:
function serve_html(cached_page) if (lighty.stat(cached_page)) then lighty.env["physical.path"] = cached_page print("Serving cached page: " .. cached_page) return true else return false end end function serve_gzip(cached_page) if (lighty.stat(cached_page .. ".gz")) then lighty.header["Content-Encoding"] = "gzip" lighty.header["Content-Type"] = "" lighty.env["physical.path"] = cached_page .. ".gz" print("Serving gzipped page: " .. cached_page .. ".gz") return true else return false end end attr = lighty.stat(lighty.env["physical.path"]) if (not attr) then lighty.env["uri.path"] = "/index.php" lighty.env["physical.rel-path"] = lighty.env["uri.path"] lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"] query_condition = not (lighty.env["uri.query"] and string.find(lighty.env["uri.query"], ".*s=.*")) user_cookie = lighty.request["Cookie"] or "no_cookie_here" cookie_condition = not (string.find(user_cookie, ".*comment_author.*") or string.find(user_cookie, ".*wordpress.*") or string.find(user_cookie, ".*wp-postpass_.*")) if (query_condition and cookie_condition) then accept_encoding = lighty.request["Accept-Encoding"] or "no_acceptance" cached_page = lighty.env["physical.doc-root"] .. "/wp-content/cache/supercache/" .. lighty.request["Host"] .. lighty.env["request.uri"] .. "/index.html" cached_page = string.gsub(cached_page, "//", "/") if (string.find(accept_encoding, "gzip")) then if not serve_gzip(cached_page) then serve_html(cached_page) end else serve_html(cached_page) end end end