Batch cleanup of Nginx cache using Shell scripts

  
                  

Today we are here to communicate on the speed of the website. Improving the speed of the website becomes very important for the operation engineers and programmers. The operation and maintenance engineers must first find and influence the various factors affecting the speed of the website in the daily operation and maintenance of the website.

Improving the speed of the website In addition to the optimization of the website itself, there is still a lot of work to be done for LinuxSA, optimizing the system kernel, adjusting the parameters of the web server, optimizing the database, increasing the cache of the website architecture, etc. work.

For the website cache, the current mainstream HTTP accelerators are mainly Varnish, Nginx_proxy, Squid, etc. As the Nginx Web high-speed reverse proxy is used by various medium-sized websites, its integrated cache function (Nginx_proxy) is also increasingly powerful. Currently, it is also widely used in enterprises. Today we will look at how the Nginx_Proxy cache is effectively cleaned 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 Determine if the script has input, no input and then exit

if

[ "$#" -eq "0" ];then

echo "Please Insertclean Nginx cache File, Example: $0 index.html index.js"

sleep 2 && exit

fi

echo "The file : $FILEto be clean nginx Cache , please read ....."


#Wrap processing for the input file, for grep lookup, Wrap the input file for grep to find matching content

for i in `echo $FILE

Copyright © Windows knowledge All Rights Reserved