This cgi script is written in perl and used to clean up multiple nginx cache servers. Usage: place the script on a web server that can execute the cgi program. Open the browser to access this script and enter the CSS or image address to be cleaned up. If you want to clear multiple caches, enter one address in one line. Code :#! /Usr/bin/perl
Use strict;
Use warnings;
Use CGI;
My $ req = new CGI;
Print $ req-> header;
Print <HTML;
<Form method = "post" action = "post. cgi "name =" form "> <textarea name = url rows = 5 cols = 60> </textarea> <P> <input type = submit> <input type = reset> </form> HTML my $ url = $ req-> param ("url ");
$ Url = ~ Tr/+ //;
$ Url = ~ S/% ([a-fA-F0-9] [a-fA-F0-9])/pack ("C", hex ($1)/eg;
My @ url = split/\ n/, $ url;
Foreach (@ url ){
My $ purge_url =$ _;
If (/http: \/(\ S + ?) (? = \/)/){
If ($1 ){
My $ squid_req = system ("squidclient-h $1-p80-mPURGE $ purge_url ");
Print $ squid_req;
}
}
}
This article is from the "mcshell learning blog" blog, please be sure to keep this source http://mcshell.blog.51cto.com/803455/910822