Reference:
Https://www.varnish-cache.org/docs/4.1/users-guide/increasing-your-hitrate.html
Translated content:
So far, your varnish has run up and you can access your web app through varnish. Unless your Web application starts writing at the back of a Web accelerator, you will need to change your profile or application in order to increase the cache hit ratio.
Varnish will not cache your data unless it is absolutely certain that it is safe to do so. So you need to know whether Varnish decides and how to cache a page. We will guide you through the use of 32 tools, both of which are very useful for understanding what will happen if you understand the settings of Varnsh.
Note: You need a tool to look at the HTTP header information between the varnish and the back-end server, there is an easy way to use Varnishlog and varnishtop (both commands), but sometimes a client-side tool will be clearer (such as the Curl command). This is what we usually use.
You can use Varishtop to view the URLs that are being requested to the backend server. Using Varnishtop-i Berequrl is one of the best and most essential commands. Shows that the highest request was sent to the backend. You can see some other examples using varnishtop
I like to use:
Varnishtop-i Requrl #查看那个url访问最多
Varnishtop-i Berequrl # through the varnish to the back end of the request that much, is generally excluded from Miss high reason
When you are sure to send the next URL frequently to the back-end server, you can use Varnishlog to view the request,
Varnishlog-q ' Requrl ~ ' ^/foo/bar ' It will display a request from the client to match/foo/bar.
For more information about Varnishlog's work, see the Loggin in varnish section, or the man help documentation.
Https://www.varnish-cache.org/docs/4.1/users-guide/operation-logging.html
Lwp-request is tool, a part of the World-wide Web library for Perl.
is a Perl-language open Source tool that is available on CentOS install using yum install Perl-libwww-perl.
We use the GET and head commands, which can show the HTTP response of the requested HTTP head and response in detail.
$ Get-h ' Host:www.vg.no '-used http://vg.no/GET http://vg.no/Host:www.vg.noUser-Agent:lwp-request/5.834 libwww-perl/ 5.834200 OKCACHE-CONTROL:MUST-REVALIDATEREFRESH:600TITLE:VG NETT-FORSIDEN-VG nettx-age:463x-cache:hitx-rick-would -never:let you downx-vg-jobb:http://www.finn.no/finn/job/fulltime/result?keyword=vg+multimedia Merk: Headerninjax-vg-korken:http://www.youtube.com/watch?v=fcj8cnd5188x-vg-webcache:joaniex-vg-webserver:leon
-H Add Request header
-U Print Request headers,
-S prints response status,
-e Prints Response headers and
-D discards the actual content
A Firefox plug-in that can display the requested and received header information.
With each HTTP request and response, this header information metadata is carried. Varnish examines these header information to determine how to cache the content in the appropriate way and determine the length of the cache.
Please note that varnish considers these headers, varnish is actually considering himself as part of the Web server. The basis of this theory is under your control. (The following sentence is not good translation )
Please note this when Varnish considers these headers Varnish actually considers itself part of The actual webserver. The rationale being that both is under your control.
This proxy cache source is not well defined in the IETF and RFC 2616, so varnish may work differently than you expect.
Let's take a look at these important heads that you need to know.
This article is from "Swallow Lie triple" blog, please be sure to keep this source http://cuidehua.blog.51cto.com/5449828/1869745
Varnish translation Achieving a high hitrate how to achieve a higher hit ratio