compress files to save on traffic
parent
a0ca26bd2e
commit
21fdb6181f
|
@ -0,0 +1,13 @@
|
|||
#!/bin/zsh
|
||||
# Copyright muflax <mail@muflax.com>, 2012
|
||||
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>
|
||||
|
||||
setopt RE_MATCH_PCRE
|
||||
|
||||
echo "compressing 'out'..."
|
||||
|
||||
for f in out/**/*(.); do
|
||||
if [[ $f =~ "\.(html|css|xml|js)$" ]]; then
|
||||
gzip --best -f -v -c "$f" > "$f.gz"
|
||||
fi
|
||||
done
|
|
@ -1,6 +1,14 @@
|
|||
# manual 404 page
|
||||
ErrorDocument 404 /404/index.html
|
||||
|
||||
# don't alienate people who use the old feed
|
||||
# rewrite stuff
|
||||
RewriteEngine on
|
||||
|
||||
# don't alienate people who use the old feed
|
||||
RewriteRule ^feed/? /rss.xml
|
||||
|
||||
# serve gzipped files if available
|
||||
RewriteCond %{HTTP:Accept-Encoding} gzip
|
||||
RewriteCond %{REQUEST_FILENAME} !\.gz$
|
||||
RewriteCond %{REQUEST_FILENAME}.gz -f
|
||||
RewriteRule ^(.*)$ $1.gz [L]
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# compress all text files in out/ to save on traffic
|
||||
|
||||
namespace :compress do
|
||||
desc "compress html (and related) files"
|
||||
task :html do
|
||||
system "./compress-html.sh"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "compress everything"
|
||||
task :compress => ['compress:html']
|
|
@ -17,4 +17,4 @@ namespace :publish do
|
|||
end
|
||||
|
||||
desc "publish complete site"
|
||||
task :publish => ['publish:push', 'publish:deploy']
|
||||
task :publish => ['publish:push', 'compress', 'publish:deploy']
|
||||
|
|
Loading…
Reference in New Issue