Varnish
Upcoming SlideShare
Loading in...5
×
 

Varnish

on

  • 1,646 views

This presentation was done by Alexander Kuznecov, our main System Administrator about Varnish Caching during Drupal Camp Kiev 2012.

This presentation was done by Alexander Kuznecov, our main System Administrator about Varnish Caching during Drupal Camp Kiev 2012.

Statistics

Views

Total Views
1,646
Views on SlideShare
1,642
Embed Views
4

Actions

Likes
0
Downloads
21
Comments
0

1 Embed 4

https://twitter.com 4

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Varnish Varnish Presentation Transcript

  • Varnish Varnish Tips and Tricks
  • VarnishHTTP-accelerator Clients Request Web server
  • VarnishHTTP-accelerator Request Clients Request Web server Request
  • VarnishHTTP-accelerator Request Clients Request Web Fault server Request
  • VarnishHTTP-accelerator RequestClients Web Request Varnish Request server Request Initial Subsequent
  • Varnish start Flow recv hash pass lookup fetch pipe miss hit deliver error done
  • Varnish ESI Page ESI content block TTL: 0 ESI block TTL: 60m TTL: 5m
  • Varnish ESI <esi:include src="/esi/region/123" />
  • VarnishVMODsEssential Varnish Modules * EXTEND FUNCTIONALITY * DISTRIBUTION BY SOURCE CODE (C)
  • Varnish Tips and Tricks
  • VarnishDrupal: cache anonymous req.http.Cookie recv SESS(.{32})=([^;]*) cookie pass
  • VarnishDrupal: cache anonymous req.http.Cookie recv SESS(.{32})=([^;]*) cookie pass
  • VarnishDrupal: cache both req.http.Cookie recv custom cookie pass
  • VarnishTools * varnishadm * varnishtop * varnishstat * varnishlog * varnishnsca * varnishd -C -f /path/to/vcl
  • VarnishCache Invalidation - full cache invalidation Varnish restart - permissions - downtime + regular expressions varnishadm - access to terminal + remote call wget / curl - single URL (PURGE HTTP method)
  • VarnishMobile User-Agents req.http.user-agent recv User Agent condition hash redirect
  • VarnishBackends backend default { .host = "192.168.0.1"; .port = "80"; } backend other { .host = "192.168.0.33"; .port = "80"; }
  • Varnish ACL acl internal { "127.0.0.1"; "localhost"; } acl admins { "192.168.1.1"; "192.168.2.0/24"; ! "192.168.2.88"; }
  • VarnishVirtual hostsinclude "/etc/varnish/virtual-hosts/example.com.vcl";sub vcl_recv { if (req.http.Host ~ "^example.com") { call explcom_vcl_recv; }}
  • VarnishHTTP-authentication recv HTTP auth pass
  • VarnishHTTP-authentication recv req.http.Authorization !HTTP auth header error
  • Varnish HTTP-authenticationif (! req.http.Authorization ~ "Basic Zm9vOmJhcgo="){ error 401 "Restricted";}$ echo -n "foo:bar" | base64
  • VarnishErrorif (obj.status == 400) { set obj.http.Content-Type = "text/html; charset=utf-8"; synthetic {" <html> <head> <title>400 Bad request</title> </head> <body> <h1>Error 400 Bad request</h1> <p>Bad request</p> </body> </html>"}; return (deliver);}
  • VarnishCustom error pages Methods: * Strict HTML * Inline C * Combined
  • VarnishRedirects ERROR
  • Varnish recvRedirects condition custom error code error error code action
  • Varnish Geolocation VMOD «GeoIP»set req.http.X-Country-Code = geoip.client_country_code(); recv GeoIP header condition restrict redirect access
  • VarnishCustom TTLset beresp.ttl = 10m;if (beresp.http.X-TTL) { C{ char *ttl; ttl = VRT_GetHdr(sp, HDR_BERESP, "06X-TTL:"); VRT_l_beresp_ttl(sp, atoi(ttl)); }C}
  • Varnish Questions ?
  • Varnish Alexander Kuznecov akuznecov@adyax.com