Nginx series (15 nginx clear cache)

Source: Internet
Author: User
: This article mainly introduces the Nginx series (clearing the cache for nginx on the 15th day). If you are interested in the PHP Tutorial, refer to it. I. nginx module cleanup

1 .:
Http://labs.frickle.com/nginx_ngx_cache_purge/
Https://github.com/FRiCKLE/ngx_cache_purge

2. Installation

./configure --prefix=/web/nginx --with-http_stub_status_module--with-pcre--add-module=/download/ngx_cache_purge-master/

3. configuration

server {         listen80;        server_name www.test01.com;        location / {            proxy_cache cache_one;            proxy_cache_valid2003041h;            proxy_cache_key$host$uri$is_args$args;            proxy_passhttp://webserver;            proxy_redirectoff;            proxy_set_header Host $host;            proxy_set_header X-Real-IP $remote_addr;            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        }        location~ /purge(/.*) {            allow127.0.0.1;            allow192.168.27.1;            deny all;            proxy_cache_purge cache_one $host$1$is_args$args;        }    }

4. test

Original url: http://www.test01.com/Public/Assets/style/default_page.css
Clear Cache url: http://www.test01.com/purge/Public/Assets/style/default_page.css

If the following interface is displayed, it is successfully cleared:

II. php cleanup

$ CachePath = '/web/cache/nginx/'; $ listcon = file_get_contents ('. /urls.txt '); $ listarr = explode ("\ n", $ listcon); foreach ($ listarras $ listval) {if (! Empty ($ listval) {$ url = md5 ($ listval); $ cacheFile = $ cachePath. substr ($ url,-1, 1 ). '/'. substr ($ url,-3, 2 ). '/'. $ url; echo $ cacheFile; if (! File_exists ($ cacheFile) {echo 'the cache does not exist! ';} Else {if (unlink ($ cacheFile) {echo 'cache cleared successfully';} else {echo 'cache cleared failed ';}}}}

Refer:

Http://www.bhqb.org/blog/post-450.html
Http://xwsoul.com/posts/460

The above describes the Nginx series (clearing cache for nginx on the 15th Five-Year Plan), including some content. I hope my friends who are interested in PHP tutorials will be helpful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.