Article From:


Command: varnishadm [-t timeout] [-S secret_file] [-T address:port] [-n name] [command […]]

 ./varnishadm -T
  • -t timeout:Waiting for an operation to complete, per unit of seconds
  • -S secret_file:Determine an authenticated security file
  • -T address:port:Connect to the address and port of the management interface, specify when you start Varnish.
  • -n name:The name of the connection to the management interface is specified when starting Varnish.

CLIThe main function is to complete the following functions

  • Configuration: can upload, modify, and delete VCL files
  • Parameters: can view and modify various parameters
  • Clear cache: can clear cache contents in Varnish.
  • Process management: you can start or stop the cache process.

CLIA common command

backend.list:List the backend in the definition, including their health status.


vcl.load configname filename:Create a new configuration, the name of which is configname, and the content is filename specified file content. configname:Display the specific content of the configuration
vcl.use configname:Which configuration is used

vcl.list:List the available configurations and refer to the number of users using them.


ban field operator argument [&& field operator argument […]]:Causes the contents of the matching ban expression to be cleared from the cache.

  • An ban expression consists of one or more conditions, a condition consisting of a field, an operator, a parameter, and a “& &amp” between multiple conditions to represent the relationship of and.
  • Fields can be arbitrary VCL variables, such as: req.url, or obj.http.set-cookie, etc.
  • The operators are: = = = equal, ~ match regular expressions, &gt, <! etc.
  • A parameter can be a string derived from double quotes or regular expressions or numbers. The numbers can be followed by “KB”, “MB”, “GB” or “TB”.
  • The examples are as follows:

The clear request URL matches the cache content of “/news” completely: ban req.url = = “/news”.
The clearing request URL cannot end with.Ogg, and the object size can not be greater than the cache content of 10M ban req.url! ~.Ogg$; & & obj.size > 10MB
Clear host for or, and get cache content from userid=1663 in backend header.
  ban ~ “^(?i)(www\.)$” && obj.http.set-cookie ~”USERID=1663


ban.list:Content ban list.

  • If the content of the cache is older than ban, then the cached content will be marked as banned, which can no longer be used.
  • Caching content, you need to get content from the backend.
  • If Ban’s expression is older than all cache objects, it will be removed from the list of ban.
  • ban.listThe format of the output is as follows:

0x7fea4fcb0580 1303835108.618863 131G ~ &&req.url ~ /some/url
The first field is the address of ban, the second field is the timestamp, and the third field represents the number of objects.
Affected by this ban (usually valid at debug), G indicates that the ban is Gone and will no longer be valid.
The content behind is the true ban content.

quit:Exit CLI management

help [command]:Displays command help and displays all commands without writing commands.




Link of this Article: Varnish CLI management

Leave a Reply

Your email address will not be published. Required fields are marked *