rc-httpd/handlers/serve-static: restore simple test for file type and hardcode max_age to 1 hour (thanks eekee)

This commit is contained in:
stanley lieber 2014-07-11 23:24:27 -04:00
parent fafc17b049
commit b46a3ee95f

View file

@ -17,11 +17,23 @@ if(! test -r $full_path){
exit exit
} }
do_log 200 do_log 200
type=`{file -m $full_path} switch($full_path){
if(~ $type text/*) case *.html *.htm
max_age=3600 # 1 hour type=text/html
if not case *.css
max_age=604800 # 1 week type=text/css
case *.txt
type='text/plain; charset=utf-8'
case *.jpg *.jpeg
type=image/jpeg
case *.gif
type=image/gif
case *.png
type=image/png
case *
type=`{file -m $full_path}
}
max_age=3600 # 1 hour
echo 'HTTP/1.1 200 OK'^$cr echo 'HTTP/1.1 200 OK'^$cr
emit_extra_headers emit_extra_headers
echo 'Content-type: '^$type^'; charset=utf-8'^$cr echo 'Content-type: '^$type^'; charset=utf-8'^$cr