Currently, my site is using an Apache pass-through to serve up Boost's static HTML files through Lighty. However, I noticed that because Lighty was not setting the proper Cache-Control header & was setting ETags for .html files, that Boost's files were showing up in the browser cache. This was causing pages to sometimes appear as if the user was still logged in when the user was logged out, or vice versa.

In order to fix this, I had to add some lines to lighttpd.conf equivalent to the Cache-Control lines in .htaccess. Here they are:

## change Cache-Control & ETag headers for .html files (needed for Boost)
$HTTP["url"] =~ "\.html$" {
  setenv.add-response-header = ( "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" )
  etag.use-inode = "disable"
  etag.use-mtime = "disable"
  etag.use-size = "disable"
}

Note that your version of Lighty must be > 1.4.16 in order for the etag settings to work (as per http://redmine.lighttpd.net/issues/1209). Also, you must have mod_setenv enabled for the setenv.add-response-header setting to work.

Comments

mikeytown2’s picture

here's an alt way. It allows for browser caching to work with boost correctly... although it's a little crazy.
#514156: disable clean url's for all logged in users; allow for browser to cache pages.

EvanDonovan’s picture

Hmm...that seems to serve a different use case than what I was looking into. The code I posted for Lighty is just a direct equivalent of the Cache-Control code from the default Boost .htaccess.

eyecon-1’s picture

I am using lighty 1.4.22. Those rules don't seem to work. Boost is creating the cache files were they belong /cache/domain but lighty isn't using them. I have no "cached by boost" legend at the bottom of the source. If I run apache, boost works as expected.

$HTTP["url"] =~ "\.html$" {
  setenv.add-response-header = ( "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" )
  etag.use-inode = "disable"
  etag.use-mtime = "disable"
  etag.use-size = "disable"
}

url.rewrite-final = ("^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2",
                          "^/search/(.*)$" => "/index.php?q=search/$1",
                          "^/([^.?]*)$" => "/index.php?q=$1",
			  "^/([^.?]*\.xml|pdf)$" => "/index.php?q=$1"
                        )

Are you using a lua recipe?

EvanDonovan’s picture

I'm not using Lighty exclusively. I'm using an Apache pass-through, so I don't need any rewrite rules for the Boost URLs. All that is handled in my .htaccess. This issue is specifically just about the Cache-Control rules, since I don't use Lighty to serve up non-cached pages on my site.

mikeytown2’s picture

Status: Needs review » Closed (duplicate)

Going to mark this a dup of the Lighttpd thread
#150909: Lighttpd rewrite rules wanted