26
October
2011

Settings mod_expire and mod_compress in Lighttpd

Last post I told you how to set mod_expire in apache, users mailed me how to set it in lighttpd.

First you need to uncomment the module in modules.conf (some lighttpd configs have this modules in lighttpd.conf itself)

server.modules = (
“mod_access”,
“mod_fastcgi”,
#  “mod_alias”,
#  “mod_auth”,
#  “mod_evasive”,
#  “mod_redirect”,
“mod_rewrite”,
#  “mod_setenv”,
#  “mod_usertrack”,
“mod_expire”,
“mod_compress”,
“mod_flv_streaming”,
“mod_h264_streaming”
)

The order of the module loading is important in lighttpd, so keep this order and you will be fine.

Example1 mod_expire:

#You can add this above your rewrite rules.conf
# mod_expire - image files expire 2 days after first access
$HTTP["url"] =~ "\.(gif|GIF|jpg|JPG|png|PNG|swf|SWF|ico|ICO)$" {
expire.url = ( "" => "access 2 days" )
}
# mod_expire - includes expire 1 day after first access
$HTTP["url"] =~ "\.(css|CSS|js|JS)$" {
expire.url = ( "" => "access 1 days" )
}
# Some versions of lighttpd may require the following directives for full functionality, uncomment if needed.
etag.use-inode = "enable"
etag.use-mtime = "enable"
etag.use-size = "enable"
static-file.etags = "enable"

Example2 mod_compress:
#mod_compress stores the compressed files to your filesystem and the second time the file is requested it will be send from your disk, only this time compressed.

$HTTP["host"] == "yourdomain.ltd" {
  compress.cache-dir         = "/tmp/compress.tmp/"
  compress.filetype          = ("text/plain", "text/javascript", "text/css", "text/xml")
}

Lighttpd is a good webserver but a little harder to setup then apache, if you need more help or a professional server setup, use the contact form to contact me.

Author: rouge
Posted in: Uncategorized

Tags: , ,

Trackback from your site.

Leave a comment

You must be logged in to post a comment.