Varnish4 clear caching methods are mainly, through Varnishadm management, or VCL configuration.
The VCL configuration allows the client to manually request a clear cache to ensure that local data is updated in a timely manner without restarting the varnish server.
Configuration method:
#允许清除缓存IP集acl purge_ip{"127.0.0.1"; "LocalHost";} Sub Vcl_recv {if (req.method ~ "Update") {if (client.ip ~ purge_ip) {return (purge);//Clear Cache} retur N (Synth (404, "not Found")); }}sub vcl_purge{return (synth, "success");}
After restarting varnish, open Firefox browser, go to a cache page, right-click to view the source code, and then select the network.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/71/AC/wKioL1XWrsbwPhVUAAFXMJgDeys525.jpg "title=" QQ picture 20150821124403.png "alt=" Wkiol1xwrsbwphvuaafxmjgdeys525.jpg "/>
Click the first request message.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/71/AC/wKioL1XWr4eT2GxOAARy5G0x7oY392.jpg "style=" float: none; "title=" qq20150821124508.jpg "alt=" Wkiol1xwr4et2gxoaary5g0x7oy392.jpg "/>
Click Edit and re-send
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/71/B0/wKiom1XWrXjQy66wAALfb3NwUMQ854.jpg "style=" float: none; "title=" qq20150821124610.jpg "alt=" Wkiom1xwrxjqy66waalfb3nwumq854.jpg "/>
Modify the request type to PURGE and click Send
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/71/AC/wKioL1XWr4jiw_fUAAH-qMq9lDk559.jpg "style=" float: none; "title=" qq20150821124643.jpg "alt=" Wkiol1xwr4jiw_fuaah-qmq9ldk559.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/71/AC/wKioL1XWsU_RjukGAANsWqRbEs4406.jpg "title=" QQ picture 20150821125459.jpg "alt=" Wkiol1xwsu_rjukgaanswqrbes4406.jpg "/>
Review the return status and, if successful, clear the cache, press F5 to refresh the page and view the new content.
Note: VARNISH4 is not configured in the same way as VARNISH3, so this configuration can only be used in the same way as VARNISH4,VARNISH3, which is used in Vcl_hit purge; The command then returns an error of "success", VCL_RECV should use return (lookup), and then do not forget to add reg.request== "PURGE" judgment.
This article is from the "gangbusters" blog, make sure to keep this source http://php2012web.blog.51cto.com/5585213/1686810
Varnish4 Configure manual Purge cache