Your SlideShare is downloading. ×
0
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Drupalcamp gent-2012 - varnish for dummies
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Drupalcamp gent-2012 - varnish for dummies

4,596

Published on

My drupalcamp Gent slideshow for varnish for drupal. …

My drupalcamp Gent slideshow for varnish for drupal.

varnish is a reverso proxy cache or web accelerator.

- Brief explenation of caching mechanisms
- what is and what does varnish
- code examples of loadbalancing
- code examples of caching improvements
- code examples of caching for drupal
- code examples of caching for mobile
- how to do edge side includes

Follow me on twitter: drupal_sensei

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,596
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
116
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Varnish for Dummies Frederik Wouters 1.
  • 2. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Debugging!   Mobile!   ESI 2.
  • 3. IntroductionFrederik Wouters•  2010 - 05/2012 Amplexor•  05/2012 - ? Self employed at Wieni Drupal Solr Varnish Apache Lighttpd Jquery … 3.
  • 4. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Debugging!   Mobile!   ESI 4.
  • 5. Introduction Client ProxyClient network cache Caching DMZ Reverse proxy Loadbalancing Caching Webserver Opcode Database User Storage caching Caching caching 5.
  • 6. Opcode CachingOpcode cache mechanisms preserve the generated code incache so that it need only be generated a single time to serverhundreds or millions of subsequent requests.Enabling opcode cache will reduce the time it takes to generatea page by up to 90%.! Adv? Php code executed a lot 6.
  • 7. Opcode Caching - Alternatives Alternative PHP Cache (APC) eAccelerator ionCube PHP Accelerator Turck MMCache XCache Nusphere PhpExpress Zend Optimizer+ Zend Platform Windows Cache Extension for PHP! 7.
  • 8. Query CachingYou can setup that up in /etc/my.cnf (Red Hat) or /etc/mysql/my.cnf (Debian) file:# vi /etc/my.cnf!Append config directives as follows:query_cache_size = 268435456!query_cache_type = 1!query_cache_limit = 1048576! Adv? many (read) queries 8.
  • 9. User Storage CachingInside The CMS Outside the CMS-  Drupal caching -  Memcache-  Boost -  Redis-  Expire module -  MongoDB-> Use expensive apache memory-> Use expensive database connections Adv? Global Data used a lot Over mutliple requests ( > x/req ) 9.
  • 10. Proxy CachingHappens at the client (network) side.Reduces Outgoing trafficApache does proxy cachingSquid is good Client network Adv? files/requests that are often used 10.
  • 11. Reverse Proxy Caching Happens at the server side. Reduces incoming traffic Also called web-accellerator!   Drupal(on apache) Response Time : 500 ms!   Varnish Response Time : 50 ms!   Capacity multiplies by x DMZ Adv? files/requests that are often used 11.
  • 12. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Debugging!   Mobile!   ESI 12.
  • 13. Content Delivery NetworkReturn files from servers located in your area Adv? Speed 13.
  • 14. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Debugging!   Mobile!   ESI 14.
  • 15. Varnish!   Drupal(on apache) Response Time : 500 ms!   Varnish Response Time : 50 ms!   Server load î = Capacity ì = #WIN 15.
  • 16. Varnish 16.
  • 17. Varnish 17.
  • 18. Varnish - installationInstallation
"Ubuntu = apt-get install varnish!!Redhat = yum install varnish!!Suse = package available (at your own risk)!!Mac = sudo port install varnish!!Also available on Mac/(open)solaris/FreeBSD/!!Windows(Cygwin)!
! 18.
  • 19. Varnish - installationConfiguration - Basics!"# file /etc/default/varnish!
#Default http port = 6081 !#Default console port = 6082!#I Prefer Port 80.!!DAEMON_OPTS="-a :6081 80 ! -T localhost:6082 ! -f /etc/varnish/default.vcl ! -S /etc/varnish/secret ! -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"!!! 19. !
  • 20. Varnish - installation Configuration – Advanced! 
 # file /etc/default/varnish! ! VARNISH_VCL_CONF=/etc/varnish/default.vcl! VARNISH_MIN_THREADS=1! VARNISH_MAX_THREADS=5000! VARNISH_THREAD_TIMEOUT=120! KINEPOLIS_VARNISH_STORAGE="malloc,4G”! KINEPOLIS_CONNECT_TIMEOUT="connect_timeout=600
 VARNISH_TTL=900
 ! DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} ! -f ${VARNISH_VCL_CONF} ! -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:$ {VARNISH_ADMIN_LISTEN_PORT} ! -t ${VARNISH_TTL} ! -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},$ {VARNISH_THREAD_TIMEOUT} ! -u varnish -g varnish ! -s ${KINEPOLIS_VARNISH_STORAGE} ! -p ${KINEPOLIS_CONNECT_TIMEOUT} ! -p thread_pools=2 ! -p thread_pool_min=200 ! 20. -p thread_pool_max=5000 !
  • 21. Varnish - installation Configuration – Ready! 
 #Start your engines! Sudo /etc/init.d/varnish start|restart! ! ! ! #The site is already Live? Do some hotswapping:! ! #login to the varnish admin console! varnishadm -T localhost:6082! ! #compile the vcl file! Vcl.load caching_vx /etc/varnish/default.vcl! ! #Switch to new compiled vcl file! Vcl.use caching_vx! ! #quit the admin console! quit! ! ! ! 21.
  • 22. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Debugging!   Mobile!   ESI 22.
  • 23. VCL Logic!   The VCL syntax is very simple, and deliberately similar to C and Perl. Blocks are delimited by curly braces, statements end with semicolons, and comments may be written as in C, C++ or Perl according to your own preferences.!   In addition to the C-like assignment (=), comparison (==, !=) and boolean (!, && and ||) operators, VCL supports both regular expression and ACL matching using the ~ and the !~ operators.!   I will use syntax of varnish 2.1.xhttps://www.varnish-cache.org/docs/2.1/reference/index.htmlhttps://www.varnish-cache.org/docs/3.0/reference/vcl.html 23.
  • 24. Varnish – VCL Logic Backends! # file /etc/varnish/backends.vcl! ! backend default {! .host = "188.188.188.228";! .port = "80";! }! ! backend static1 {! .host = "188.188.188.229";! .port = "80";! }! ! backend static2 {! .host = "188.188.188.235";! .port = "80";! }! ! ! 24.
  • 25. Varnish - VCL Logic Backends! # file /etc/varnish/backends.vcl! ! backend default {! .host = "188.188.188.228";! .port = "80"; ! .connect_timeout = 1s;! .first_byte_timeout = 100s;! .between_bytes_timeout = 100s;! 
 #In Varnish 2.0.4 the default value for #connect_timeout is 0.4s, first_byte_timeout #and between_bytes_timeout options is 60s.! ! }! ! ! 25.
  • 26. Varnish - VCL Logic Backends! # file /etc/varnish/backends.vcl! backend default {! .host = "188.188.188.228";! .port = "80"; ! .connect_timeout = 1s;! .first_byte_timeout = 100s;! .between_bytes_timeout = 100s;! .probe = { ! .url = "/status.php"; ! .interval = 20s; #time between the polls! .timeout = 10s; #time to finish request ! .window = 2; #amount of polls needed for healthy! .threshold = 2; #amount of window polls -> healthy! }! ! }! https://www.varnish-cache.org/trac/wiki/BackendPolling! ! 26.
  • 27. Varnish - VCL Logic Backends - probe! # file /var/www/html/myapp/status.php! ! Status.php (or a drupal status url)! ! ! //Bootstrap! //DB test! //Slave DB test! //Memcache (connectivity) running! //files directory mounted! //return HTTP 200 OK! ! ! ! http://it2servu.be/statusphp-drupal-7-varnish-steroids! ! 27.
  • 28. Varnish - VCL Logic Loadbalancing = Backends = Director! # file /etc/varnish/backends.vcl! ! director web round-robin {! {! .backend = static1;! }! {! .backend = static2;! }! }! #client! #set client.identity = client.ip;! #set client.identity = req.http.user-agent;! #round Robin! #random! #fallback! 28.
  • 29. Varnish – VCL Logic DRUPAL SETTINGS! # file sites/mysite/settings.php! ! $conf[reverse_proxy] = TRUE;! $conf[reverse_proxy_adresses] = array(188.18.188.227);! $conf[cache_backends] = ! array(sites/all/modules/contrib/varnish/ varnish.cache.inc);
 ! $conf[cache_class_cache_page] = VarnishCache;! $conf[page_cache_invoke_hooks] = FALSE;
 ! $conf[cache] = 1;! $conf[cache_lifetime] = 21600; #think about this one!! $conf[page_cache_maximum_age] = 10;
 ! $conf[reverse_proxy_header] = HTTP_X_FORWARDED_FOR;! $conf[omit_vary_cookie] = TRUE;! ! ! 29.
  • 30. Varnish – VCL LogicPurging the cache from drupal!!<?php!if (module_exists(varnish)) { ! !module_load_include(module, varnish);
! !#clear only the frontpage! !_varnish_terminal_run(url.purge . $base_url);!! !#clear all Varnish cache! !_varnish_terminal_run(url.purge .’);!!}!!#There’s a module that helps you with that.!http://drupal.org/project/cache_actions !!! 30.
  • 31. Varnish – Flow So much for the proxy/loadbalancer Variables req.* request reps.* response bereq* backend request obj.* request object client.* server.* Let’s Cache 31.
  • 32. 32.
  • 33. 33.
  • 34. 34.
  • 35. 35.
  • 36. Varnish – VCL Logic Configuration – VCL Logic! # file /etc/varnish/default.vcl! ! include /etc/varnish/backends.vcl;! 
 #the most simple vcl_recv ever! sub vcl_recv {! !set req.backend = web;
 
 !#return (pipe);! ! !#pipe from server
 ! !return (pass);! ! !#fetch from server (no caching)! !#return(lookup);! ! !# delivers from cache ! }! ! 36.
  • 37. Varnish – VCL LogicVcl_deliver
!#Called before a cached object is delivered to theclient
!#makes life a little easier.!!sub vcl_deliver {! !if (obj.hits 0) {! ! !set resp.http.X-Cache = HIT;! !} else {! ! !set resp.http.X-Cache = MISS;! !}!! !set resp.http.X-Hits = obj.hits;!} !! 37.
  • 38. Varnish - Debugging 38.
  • 39. Varnish – VCL LogicVcl_fetch
#Called when the requested object has been retrieved#from the backend, or the request to the backend has#failed
!sub vcl_fetch {! !# Grace to allow varnish to serve content if backend is lagged! !set obj.grace = 5m;!! !if (!beresp.cacheable) {! !set beresp.http.X-Cacheable = NO:Not Cacheable;! !return(pass); ! !} elsif (beresp.http.Cache-Control ~ private) {! !set beresp.http.X-Cacheable = ! ! ! ! ! !NO:Cache-Control=private;! !return(pass);! !} else {! ! !set beresp.http.X-Cacheable = YES;! !}! !return(deliver); !!}! 39.
  • 40. Varnish - Debugging 40.
  • 41. Varnish – VCL Logicvcl_recv
!#forward the client IP address for drupal!set req.http.X-Forwarded-For = client.ip;
!#pipe abnormal request types!if (req.request != GET req.request != HEAD ! req.request != PUT req.request != POST ! req.request != TRACE req.request != OPTIONS req.request != DELETE) {! ! return (pipe); #Non-RFC2616 or CONNECT!}!!#only GET and HEAD requests are cacheable!if (req.request != GET req.request != HEAD) !{! !return (pass);!}! !! 41.
  • 42. Varnish – VCL Logicvcl_recv
!#Drupal7 logged in users are passed!if (req.http.Cookie ~ SESS[a-z0-9]+) {! return (pass);!}!!#in backends.vcl!acl internal {188.188.188.0/24;}!!
#Deny access from IP’s outside the DMZ!if (req.url ~ (cron|install|status).php$ !client.ip ~ internal) {! !error 404 Access is denied;! !} ! 42.
  • 43. Varnish – VCL Logicvcl_recv
!#normalize user agents (reduces cache entries)!if (req.http.user-agent ~ MSIE) {! !set req.http.user-agent = MSIE;!} else {! !set req.http.user-agent = Mozilla;!}
!# Normalize encoding request types (reduce cache entries)!if (req.http.Accept-Encoding) {! if (req.url ~ .(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$) {! # No point in compressing these! remove req.http.Accept-Encoding;! } elsif (req.http.Accept-Encoding ~ gzip) {! set req.http.Accept-Encoding = gzip;! } elsif (req.http.Accept-Encoding ~ deflate) {! set req.http.Accept-Encoding = deflate;! } else {! # unkown algorithm! remove req.http.Accept-Encoding;! }!}! 43.
  • 44. Varnish – VCL Logicvcl_recv
!#Don’t cache movies(save memory) !if (req.http.host == cd3.kinepolis.com” ||! !req.url ~ ^/admin/content/backup_migrate/export”){ ! !#CDN MODULE / backup and migrate! !return (pipe);!}!!#cache the css/javascript (save speed) !!if (req.url ~ (?i).(css|js)(?[a-z0-9=.]+)?$) {! !unset req.http.Cookie; #reduce cache entries! !return (lookup);!}!
#cache and cleanup files !if (req.url ~ (?i).(png|gif|jpeg|jpg|ico|swf|html|htm)(?[a-z0-9=.]+)?$) { ! ! unset req.http.Cookie;! ! return (lookup); #Or pass from dedicated server! 44.
  • 45. Varnish – VCL Logicvcl_recv
!#ajax
!if(! !req.url ~ ^/admin/build/features || #features! !req.url ~ ^/info/.*$ || ! !req.url ~ ^/batch/.*$ || #batch API uses AJAX! !req.url ~ ^/flag/.*$ || #batch API uses AJAX! !req.url ~ ^.*/ajax/.*$ || #custom ajax paths! !req.url ~ ^.*/ahah/.*$ || #drupal ajax paths! !req.url ~ ^.*/admin/.*$ || #admin pages! !req.url ~ ^.*/user/.*$ || #user pages! !req.url ~ ^.*token.*$” #token paths !! !) {! ! !# Dont cache, pass to Apache backend! return (pass);! !}!#Pay attention! Default drupal ahah uses POSTS = NO CACHING!#When possible GET or create your own paths w/wo “ajax”!! 45.
  • 46. Varnish – VCL LogicStale while revalidate!!Sub vcl_recv{! if(!req.backend.healthy){! !set req.grace = 5m;! }! set beresp.grace = 30m;!}!!Sub vcl_fetch{! !set req.grace = 15s;!}! 46.
  • 47. Varnish – VCL LogicStale if error!!Sub vcl_fetch{! if(beresp.status == 500 ){! set beresp.saintmode = 10s;! !return (restart);! }! set beresp.grace = 30m;!}! 47.
  • 48. Varnish – VCL LogicPurge a page!!Sub vcl_fetch{! if (req.request == PURGE) {! acl access{! if (client.ip ~ access) {! localhost;! return(lookup);! 192.168.1.0/24; ! }! !192.168.1.23; ! }! }!}!sub vcl_hit {! if (req.request == PURGE) {! set obj.ttl = 0s;! error 200 Purged.;! }!}!!sub vcl_miss {! if (req.request == PURGE) {! error 404 Not in cache.;! }!}! 48.
  • 49. Varnish – VCL Not good enough?Your own C Code!!!#Just like that:!!C{! syslog(LOG_INFO, Just served the xxxth page);!}C!!#because all is compiled to C code anyway.!!! 49.
  • 50. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Debugging!   Mobile!   ESI 50.
  • 51. Debugging!   Log files?!   Tools ¬  Firebug ¬  Varnishlog ¬  Varnishtop ¬  Varnishhist ¬  Varnishstat 51.
  • 52. Varnish Debugging! varnishlog ¬  The varnishlog utility reads and presents varnishd(1) shared memory logs. ¬  Official documentation ¬  Varnishlog Cheat sheet 52.
  • 53. Varnish - Debugging 53.
  • 54. Varnish Debugging! varnishtop ¬  The varnishtop utility reads the shared memory logs and presents a continuously updated list of the most commonly occurring log entries. With suitable filtering using the -I, -i, -X and -x options, it can be used to display a ranking of requested documents, clients, user agents, or any other information which is recorded in the log. ¬  varnishtop -i rxurl will show you what URLs are being asked for by the client. ¬  varnishtop -i txurl will show you what your backend is being asked the most. ¬  varnishtop -i RxHeader -I Accept-Encoding will show the most popular Accept-Encoding header the client are sending you. 54.
  • 55. 55.
  • 56. Varnish - Debugging! varnishhist ¬  The varnishhist utility reads varnishd(1) shared memory logs and presents a continuously updated histogram showing the distribution of the last N requests by their processing. The value of N and the vertical scale are displayed in the top left corner. The horizontal scale is logarithmic. Hits are marked with a pipe character (“|”), and misses are marked with a hash character (“#”). varnishsizes Varnishsizes does the same as varnishhist, except it shows the size of the objects and not the time take to complete the request. ¬  This gives you a good overview of how big the objects you are serving are. 56.
  • 57. Varnish - Debugging 57.
  • 58. Varnish - Debugging! varnishstat ¬  Varnish has lots of counters. We count misses, hits, information about the storage, threads created, deleted objects. Just about everything. ¬  varnishstat will dump these counters. This is useful when tuning varnish. There are programs that can poll varnishstat regularly and make nice graphs of these counters. One such program is Munin. Munin can be found at http://munin-monitoring.org/ . There is a plugin for munin in the varnish source code. ¬  See this in your drupal site (after installing the varnish module) 58.
  • 59. 59.
  • 60. !   Introduction!   Caching explained!   CDN?!   Varnish installation/configuration!   VCL Logic!   Drupal VCL rules!   Mobile!   ESI 60.
  • 61. Varnish - MobileDepends on your strategy!   Webserver handles mobile!   Redirect to mobile site!   Responsive 61.
  • 62. Varnish – MobileWebserver uses user agent!!sub normalize_user_agent {! if (req.http.user-agent ~ MSIE) {! set req.http.X-UA = msie;! } else if (req.http.user-agent ~ Firefox) {! set req.http.X-UA = firefox;! } else if (req.http.user-agent ~ Safari) {! set req.http.X-UA = safari;! } else if (req.http.user-agent ~ Opera Mini/) {! set req.http.X-UA = opera-mini;! } else if (req.http.user-agent ~ Opera Mobi/) {! set req.http.X-UA = opera-mobile;! } else if (req.http.user-agent ~ Opera) {! set req.http.X-UA = opera;! } else {! set req.http.X-UA = nomatch;! }!}!!sub vcl_recv {! !…! !call normalize_user_agent;! 62.
  • 63. Varnish – MobileRedirecting to mobile site!!#in vcl_recv!set req.http.X-Device = desktop;!if (req.http.User-Agent ~ iPad || req.http.User-Agent ~ iP(hone|od) || req.http.User-Agent ~ Android || req.http.User-Agent ~SymbianOS || req.http.User-Agent ~ ^BlackBerry || req.http.User-Agent ~ ^SonyEricsson || req.http.User-Agent ~ ^Nokia ||req.http.User-Agent ~ ^SAMSUNG || req.http.User-Agent ~ ^LG) {! !# Define smartphones, tablets and phones! !set req.http.X-Device = mobile;! !error 750;!}!!#In vcl_error !if (obj.status == 750){! !set obj.http.Location = http://kinepolis.mobi; !! !set obj.status = 302;! !return (deliver); !! }!!! 63. !
  • 64. Varnish – MobileResponsive!!#simple optimization to increase cache hit ratio!!sub normalize_user_agent {! !set req.http.X-UA = ”allthesame;!}!!sub vcl_recv {! !…! !call normalize_user_agent;! !…!}!!!! 64.
  • 65. ESI 65.
  • 66. Edge side includes!   http://en.wikipedia.org/wiki/Edge_Side_Includes!   https://www.varnish-cache.org/docs/3.0/tutorial/esi.html!   http://drupal.org/project/esi 66.
  • 67. Varnish – ESIHow it works!!#index.html!html! pVarnish will work on this page: ! esi:include src=/date.php /.! /p!/html!!#date.php!?php!echo date(Y-m-d);!!#default.vcl!sub vcl_fetch {! if (req.url == /index.html) {! set beresp.do_esi = true;! }!}! 67.
  • 68. Varnish – ESI•  Enable Drupal Modules •  ESI – Block •  ESI – Edge side includes•  Edit the caching settings of the blockLook out for ESI_xmlerror records in the varnishlog output, they will tell you thebytenumber in the file, if trouble is found during the ESI parsing.!! 68.
  • 69. Did it digest? Now’s the time to tell! Wouters.f@gmail.com Drupal_sensei 69.
  • 70. Feedback follow-up:http://drupalcampgent.be/feedback 70.

×