Varnish is a very useful 'cdn' caching software that can be used as an extension for image servers.
However, if images need to be updated frequently, an update mechanism needs to be introduced.
The varnish configuration file contains the Scheduled Update method.
However, during my use, I always find that this update method is not very effective. Varnish1.1.2 is used.
At the moment, I did not find any reason.
I just thought about updating through HTTP. The test is successful.
Write a PHP file:
<? Phpfunction varnish_purge ($ IP, $ host, $ URL) {$ errstr = "; $ errno ="; $ fp = fsockopen ($ IP, 80, $ errno, $ errstr, 10); If (! $ FP) {return false;} else {$ out = "purge {$ URL} HTTP/1.1 \ r \ n"; $ out. = "Host: {$ Host} \ r \ n"; $ out. = "connection: Close \ r \ n"; fputs ($ FP, $ out); $ out = fgets ($ FP, 4096 ); fclose ($ FP); Return true; }}$ url = $ _ Get ['U']; varnish_purge ("192.168.1.167", "MP. ×××××. com ", $ URL); varnish_purge (" 192.168.1.183 "," MP. ×××××. com ", $ URL);?> In this way, you can use the HTTP Method to update the varnish cache, but it is found that the processing speed is relatively slow. Next we are going to solve this problem.