I was not able to find a simple way to use wp-super-cache with lighttpd, some were using 100 lines lua script and the others were unreliable at best. After an hour of fiddling, I came with the following configuration.
What it does:
- It serves a cache file only if the user is not logged in.
- If no cache exists, the 404 handler loads index.php which will either find the correct page (and generate missing cache), or return a true 404.
- It does not mess with /wp-admin or /wp-content or any file that exists outside the cache.
What might not work:
- I did not test if logging works properly in lighttpd when the hit use the 404 handler. Although it should be trivial to fix
In green are the values that you will have to edit
$HTTP["host"] == "blog.alexou.net" {
server.document-root = "/var/www/wordpress"
server.error-handler-404 = "index.php"
$HTTP["cookie"] !~ "^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" {
url.rewrite-once = ( "^/wp-admin(.*)(?:\?(.*))?$" => "wp-admin$1?$2" )
url.rewrite-if-not-file = ("^/(.*)$" => "wp-content/cache/supercache/blog.alexou.net/$1" )
}
}
Note: You need lighttpd >= 1.4.24, since earlier versions do not have rewrite-if-not-file.