Foreword * With the development of the whole Internet, has produced numerous big and small website, along with the user to the website UI and the speed experience also is strengthening, to the enterprise or the individual, wins the user experience also means to win the opportunity.
So today we are here to communicate with the speed of the site, to improve the speed of the site for the operation of engineers, programmers become critical. Operational engineers must first of all in the daily website operations to find the impact of the speed of various factors to be driven and then resolved.
Improve web site speed experience in addition to its own web site program optimization, for LINUXSA, there are a lot of work to do, optimize the system kernel, adjust the parameters of the Web server, optimize the database, increase the Web site architecture cache, and so a series of work.
For Web caching, the current mainstream HTTP accelerator is mainly varnish, nginx_proxy, squid, etc., with the Nginx Web high-speed reverse proxy by the use of large and medium-sized Web sites, its integrated caching function (NGINX_PROXY) is increasingly powerful, At present, enterprises are also used in large quantities. Today we'll look at how the Nginx_proxy cache works to clean up. Use the shell script to automate the cleanup, as follows:
Copy Code code as follows:
#! /bin/sh
#Auto clean Nginx Cache Shell Scripts
#2013 -06-12 WUGK
#Define Path
cache_dir=/data/www/proxy_cache_dir/
File= "$*"
#To determine whether the input script,if not, then exit to determine if the script has input, does not enter and then exits
If
["$#"-eq "0"];then
echo "Please Insert clean Nginx cache File, Example: $ index.html index.js"
Sleep 2 && exit
Fi
echo "The file: $FILE to being clean nginx Cache, please waiting ..."
#Wrap processing for the "input" file, for grep lookup, a newline of the entered files, which facilitates grep lookup matching related content
For i in ' echo $FILE |sed ' s//\n/g '
Todo
Grep-ra $i ${cache_dir}| Awk-f ': ' {print $} ' >/tmp/cache_list.txt
For j in ' Cat/tmp/cache_list.txt '
Todo
RM-RF $j
echo "$i $j is Deleted Success!"
Done
Done
#The Scripts exec Success and exit 0
Following is a screenshot of the execution of the purge script: