利用squidclient清理nginx多台快取服務器cgi程式

來源:互聯網
上載者:User

此cgi指令碼用perl寫的,用於清理多台nginx快取服務器。使用方法:將此指令碼放在能夠執行cgi程式的web伺服器上。開啟瀏覽器訪問此指令碼,輸入需要清理緩衝的CSS或者是圖片地址,如果要清理多個緩衝,請一行輸入一個地址即可。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;
    }
  }

}

本文出自 “mcshell學習部落格” 部落格,請務必保留此出處http://mcshell.blog.51cto.com/803455/910822

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.