Created
November 13, 2014 23:04
-
-
Save demofly/0312be03d4b7e3c748e0 to your computer and use it in GitHub Desktop.
Cron job to decrease CPU usage in nginx with gzip_static enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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