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:
#! /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 insertclean Nginx cache File, Example: $ index.html index.js"
Sleep 2 && exit
Fi
echo "The file: $FILEto be 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. ' Cat/tmp/cache_list.txt ' do
RM-RF $j
echo "$i $j is deletedsuccess!"
Done
Done
#The Scripts exec Success and exit 0
Following is a screenshot of the execution of the purge script: