-
Edit conf file: /etc/lighttpd/lighttpd.conf
Enable mod_expire and mod_compress.
Expire static files set for 3 days:
$HTTP["url"] =~ "\.(js|css|gif|jpg|png|ico|txt|swf|html|htm)$" { expire.url = ( "" => "access 3 days" ) }
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ("text/plain", "text/html", "text/css", "text/xml", "text/javascript")
#!/bin/bash
# lighttpd_cache_clean
# Clean cache stored at /var/cache/lighttpd/compress
# Place in /etc/cron.daily
# Cache dir path
CROOT="/var/cache/lighttpd/compress"
#Deleting files older than 3 days
HOURS=72
# Lighttpd user and group
LUSER="lighttpd"
LGROUP="lighttpd"
# start cleaning
/usr/sbin/tmpwatch --mtime ${HOURS} ${CROOT}
# if directory missing just recreate it
if [ ! -d $CROOT ]
then
mkdir -p $CROOT
chown ${LUSER}:${LGROUP} ${CROOT}
fi
exit 0
mkdir -p /var/cache/lighttpd/compress
chown lighttpd:lighttpd /var/cache/lighttpd/compress