0VPS القرص لتحسين الأداء على شبكة الإنترنت

في حين أنني لم كتب العديد من المقالات الجديدة مؤخرا لقد قضيت وقتا طويلا تحديث وتنقيح الجانب وراء الكواليس من الأشياء, الأمن وهي مختلفة (TLS) الإعدادات على بلدي VPS الذي يستضيف عدة مواقع بما في ذلك هذا واحد. شيء آخر لقد عملت أيضا على تعزيز مؤخرا هو تحسين لغتي استخدام غزيب, وشكل جديد يسمى brotli

موجز, غزيب (وbrotli) can be used to com­press resources before they are sent to the browser, مما يقلل من كمية البيانات المرسلة, and hence should mean a site loads faster. The down­side is that com­press­ing resources takes time, which could out­weigh the gains from the smal­ler sizes. The ideal solu­tion is to have resources com­pressed in advance, rather than com­pressed by the http serv­er in real­time. Most of my web­sites use word­press which con­tains lots of files in plu­gins, الموضوعات الخ, so going through all of these and manu­ally com­press­ing them everytime there is an update would be imprac­tic­al. The answer is to use a script which mon­it­ors the sys­tem for file changes, and cre­ates com­pressed files as needed. Below is the script I have recently writ­ten to do exactly this.

#!/bin/bash                               

inotifywait -m -q -e CREATE -e MODIFY -e MOVED_TO -r "/فار / على شبكة الاتصالات العالمية /" --شكل "%ث٪ و" --excludei '.(JPG|بابوا نيو غينيا|GIF|منظمة البن الدولية|سجل|مزود|الرمز البريدي|جي زد|قوات الدفاع الشعبي|فب|فرنك سويسري|الصناديق|EOT|WOFF|جنة العلم والتكنولوجيا|JST|ر|سنت)$' |
while read file
do
if [[ $ملف = ~ \.(المغلق)$ ]];
then
fname="${ملف٪.*}"
إذا [ -و "$fname".min.css ]
then
rm -f $file.gz
rm -f $file.br
zopfli --gzip $file
bro --quality 11 --input $file --output $file.br
chmod 664 $file.br
chmod 664 $file.gz
chown wordpress:wordpress $file.br
chown wordpress:wordpress $file.gz
else
rm -f $file.gz
rm -f $file.br
cat $file | cleancss > $fname.cst
cat $file | cleancss | إخوانه --quality 11 --output $file.br
zopfli --gzip $fname.cst -c > $fname.css.gz
chmod 664 $file.br
chmod 664 $file.gz
chown wordpress:wordpress $file.br
chown wordpress:wordpress $file.gz
rm -f $fname.cst
fi
fi

if [[ $ملف = ~ \.(شبيبة)$ ]];
then
fname="${ملف٪.*}"
إذا [ -و "$fname".min.css ]
then
rm -f $file.gz
rm -f $file.br
zopfli --gzip $file
bro --quality 11 --input $file --output $file.br
chmod 664 $file.br
chmod 664 $file.gz
chown wordpress:wordpress $file.br
chown wordpress:wordpress $file.gz
else
rm -f $file.gz
rm -f $file.br
uglifyjs $fname.js > $fname.jst
zopfli --gzip $fname.jst -c > $fname.js.gz
bro --quality 11 --input $fname.jst --output $file.br
chmod 664 $file.br
chmod 664 $file.gz
chown wordpress:wordpress $file.br
chown wordpress:wordpress $file.gz
rm -f $fname.jst
fi
fi

origfs=$(مرحاض -c < "$ملف")
gzfs = $(مرحاض -c <"$file.gz")
brfs = $(مرحاض -c <"$file.br")

إذا [ "$origfs" -لتر "$gzfs" ];
then
rm $file.gz -f
fi
if [ "$origfs" -لتر "$brfs" ];
then
rm $file.br -f
fi

done

Leave a Reply