Skip to content

Instantly share code, notes, and snippets.

@demofly
Created November 13, 2014 23:04
Show Gist options
  • Save demofly/0312be03d4b7e3c748e0 to your computer and use it in GitHub Desktop.
Save demofly/0312be03d4b7e3c748e0 to your computer and use it in GitHub Desktop.
Cron job to decrease CPU usage in nginx with gzip_static enabled.
#!/bin/bash
for ext in css js
do
find /var/www -type f -name "*.${ext}" | while read f
do
gzip -c9 "$f" > "$f.gz.new"
diff "$f.gz.new" "$f.gz" 2>/dev/null && rm -f "$f.gz.new" || mv -vf "$f.gz.new" "$f.gz"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment