: 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.