Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Browser-Caching for lighttpd/thin

I have the problem that Googles “Page Speed” says that I should enable browser caching.

I am usein a lighttpd server as a proxy for different web server on my server. One of them is a rails app (Ruby 1.9.2/Rails 2.3.x) running with thin server.

I thought that I have to enable “mod_expire” in the lighttpd proxy and use the settings:

expire.url = ("/favicon.ico"  => "access plus 7 days",
         "/stylesheets/" => "access plus 7 days",
         "/javascripts/" => "access plus 7 days",
         "/images"        => "access plus 7 days"
         )

But it did not work. I also moved the expire.url code to:

$HTTP["host"] =~ "myRailsApp" {
  expire.url = ...
  proxy.balance = "fair"
  proxy.server = (
    "/" => (
    (
      "host" => "11.22.33.44",
      "port" => 2000
    ),
    (
      "host" => "11.22.33.44",
      "port" => 2001
    )
  )
}

It did not work, either.

So my question is: How can I enable the browser caching for my lighttpd/thin setting?

Unfortunately, Google did not help me.

like image 400
Bjoernsen Avatar asked May 30 '26 18:05

Bjoernsen


1 Answers

It is also possible to use a condition, e.g.:

[

...]
      $HTTP["url"] =~ "^/images/" {
         expire.url = ( "" => "access plus 1 hours" )
}
[...]
like image 142
Timur Sadykov Avatar answered Jun 01 '26 10:06

Timur Sadykov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!