Update varnish cache in http mode

Source: Internet
Author: User
Tags varnish

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.

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.