SlideShare a Scribd company logo
1 of 47
Download to read offline
Varnish voor
                        webbouwers
                          Openminds TechTalk
                             6 juli 2011

                          www.openminds.be
                        Managed hosting solutions




Wednesday 6 July 2011
SOFTWARE




Wednesday 6 July 2011
Varnish

                   • Noorse tabloid Verdens
                        Gang - 1.0 in 2006 - 3.0
                        enkele dagen terug

                   • Snelheidswinst site: 10x -
                        300x

                   • caching HTTP reverse proxy


Wednesday 6 July 2011
normaal


                        Client
                                  Internetlijn
                                                   Server




                                                 Datacentrum


Wednesday 6 July 2011
klassieke proxy

                                 Trage Internetlijn
          Client
          Client         Proxy                         Server
           Client




                                                      Datacentrum


Wednesday 6 July 2011
reverse proxy

          Client        Snelle lijnen
          Client
           Client                          Proxy      Server




                                        Datacentrum


Wednesday 6 July 2011
reverse proxy

          Client        Snelle lijnen
          Client
           Client                          Proxy      Server
                                                       Server
                                                        Server




                                        Datacentrum


Wednesday 6 July 2011
caching reverse proxy

          Client                    Caching
          Client
           Client                             Server
                                               Server
                                     Proxy      Server




                            Datacentrum


Wednesday 6 July 2011
Waarom?
                   • Serverbelasting omlaag
                   • Veel snellere site-ervaring
                   • Veel meer hits/s afwerken met zelfde
                        hardware
                   • Ademruimte voor serverhits


Wednesday 6 July 2011
Wednesday 6 July 2011
Caching

                   • Identieke aanvraag - identiek antwoord
                   • We houden het volledige antwoord bij
                    • Headers
                    • Data (HTML)


Wednesday 6 July 2011
Identieke aanvraag
                        Identiek antwoord


Wednesday 6 July 2011
Aanvraag
 GET / HTTP/1.1
 Host: www.openminds.be
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Accept-Language: en,en-us;q=0.7,nl-be;q=0.3
 Accept-Encoding: gzip, deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Connection: keep-alive
 Cookie: __utma=121817557.1268321880.1308719392.1309764385.1309861948.8;
 __utmz=121817557.1308719392.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
 _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09
 Og9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db25
 0cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2Vkew
 Y7CFQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; __utmc=121817557; __utmb=121817557.2.10.1309861948




Wednesday 6 July 2011
Aanvraag
 GET / HTTP/1.1
 Host: www.openminds.be
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Accept-Language: en,en-us;q=0.7,nl-be;q=0.3
 Accept-Encoding: gzip, deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Connection: keep-alive
 Cookie: __utma=121817557.1268321880.1308719392.1309764385.1309861948.8;
 __utmz=121817557.1308719392.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
 _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09
 Og9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db25
 0cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2Vkew
 Y7CFQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; __utmc=121817557; __utmb=121817557.2.10.1309861948




Wednesday 6 July 2011
Aanvraag

                   • Host
                   • URI (pad, method/verb, version)
                   • Cookies
                   • Encoding / compressie


Wednesday 6 July 2011
Antwoord
HTTP/1.1 200 OK
Server: nginx/0.5.32
Date: Tue, 05 Jul 2011 10:52:36 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15
Etag: "25ec477310b3f81f097d5f6f3b5824f6"
X-Rack-Cache: stale, invalid, store
X-Content-Digest: af41dfcde5cfeaa55717261890560d56595be969
X-Runtime: 2559
Cache-Control: max-age=300, public
Age: 21
Set-Cookie:
_openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09O
g9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db250c
m9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2VkewY7C
FQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; path=/; HttpOnly
Content-Length: 11565
Status: 200
X-server: pro-005
X-Proxy: fosfor




Wednesday 6 July 2011
Wat cachen?
                   • Statische content (images, css, js, ...)
                   • Hoofdpagina’s / hoofdpaden
                   • Zoveel mogelijk
                   • Versie per variatie bijhouden (encoding...)
                   • GET/HEAD


Wednesday 6 July 2011
Wednesday 6 July 2011
Wat niet cachen
                   • admin/management secties
                   • pagina’s die zich aanpassen aan user (logged
                        in, winkelmandje, profielen, ...)
                   • 404 / 500 / ...
                   • POST/PUT/DELETE


Wednesday 6 July 2011
Cookies

                   • Sessie - antwoord niet cachen
                   • Google - doet er op zich niet toe
                   • Variaties - antwoord wel cachebaar



Wednesday 6 July 2011
Stel...

                   • ... dat de webapplicatie dit meegeeft
                   • browser-cache hints worden gestuurd
                   • meestal fout



Wednesday 6 July 2011
Cache-Control
HTTP/1.1 200 OK
Server: nginx/0.5.32
Date: Tue, 05 Jul 2011 10:52:36 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15
Etag: "25ec477310b3f81f097d5f6f3b5824f6"
X-Rack-Cache: stale, invalid, store
X-Content-Digest: af41dfcde5cfeaa55717261890560d56595be969
X-Runtime: 2559
Cache-Control: max-age=300, public
Age: 21
Set-Cookie:
_openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09O
g9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db250c
m9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2VkewY7C
FQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; path=/; HttpOnly
Content-Length: 11565
Status: 200
X-server: pro-005
X-Proxy: fosfor




Wednesday 6 July 2011
Cache hints
                   • max-age - eenvoudig (HTTP 1.1)
                   • expires - zeer specifiek (HTTP 1.0)
                   • “pragma: no-cache”
                   • etags
                   • ...


Wednesday 6 July 2011
Varnish manipuleert

                   • Zowel aanvraag als antwoord
                   • Strippen, herzetten, ... van velden
                   • Cookies manipuleren
                   • Cache-timings


Wednesday 6 July 2011
Cache timings

                   • De duur dat Varnish het zelf bijhoudt
                        (varnish ttl) - bvb 24 uur
                   • De duur dat een client het mag bijhouden
                        (browser cache) - bvb 2 uur of 30 dagen




Wednesday 6 July 2011
Een voorbeeld
                   • Gewone, publieke site
                   • Rails-applicatie met eigen CMS
                   • Eenvoudige VDS
                   • 100Mbps
                   • Eenvoudige varnish config (cache-control
                        was correct)




Wednesday 6 July 2011
Wednesday 6 July 2011
1 second cache

                   • Pollers
                   • 100 tot 10000 polls per seconde
                   • +/- timestamp terugsturen
                   • zorgt voor 99 tot 9999 minder hits/s


Wednesday 6 July 2011
1 second cache




Wednesday 6 July 2011
Images

                   • Hard forceren
                   • Alle cookies strippen
                   • Hogere cache-control zetten



Wednesday 6 July 2011
Talen
                   • Taal niet opslaan in sessie
                   • Taal in cookie opslaan (language=nl)
                   • Wordt een variatie voor Varnish
                    • Homepagina voor Nederlands
                    • Homepagina voor Frans


Wednesday 6 July 2011
Anonieme cookies
                   • Drupal 6
                   • Symfony
                   • CakePHP
                   • Rails
                   • ...


Wednesday 6 July 2011
Admin interfaces

                   • Volledig namespaced (/admin/...)
                   • Andere url (admin.openminds.be)
                   • Sessie-cookie verwijderen bij logout



Wednesday 6 July 2011
Logged in users

                   • Moeilijk!
                   • Assets op andere hosts/url
                   • Ajax ?
                   • Partial caching van Varnish (advanced)


Wednesday 6 July 2011
There are only two hard things in Computer Science:
                cache invalidation and naming things
                           — Phil Karlton




Wednesday 6 July 2011
Cache invalidation
                   • Wat bij edit/put/post/...
                   • eenvoudig: PURGE op juiste URL(s)
                   • control channel
                    • Drupal module
                    • Lacquer gem
                   • Purged de browser niet !!!

Wednesday 6 July 2011
Webbouwers
                   • Anonieme cookies nodig?
                   • Admin sectie duidelijk
                   • Variaties aantoonbaar (language-cookie bv)
                   • Cache-control headers zijn belangrijk
                   • Vooraf over nadenken


Wednesday 6 July 2011
Kleine sites

                   • Snelheid omhoog
                   • Zijn meestal zeer statisch
                   • Code mag zelfs iets minder performant dan
                   • Purge kan volledig zijn


Wednesday 6 July 2011
Grote projecten

                   • Performantie
                   • Beschikbaarheid
                   • Kosten drukken (minder hardware)
                   • Cache invalidation belangrijk


Wednesday 6 July 2011
Opletten voor...

                   • User-agent voor Mobile Device detection
                   • Captcha (cookies voor images?)
                   • X-Forwarded-For



Wednesday 6 July 2011
Varnish niet voor


                   • Grote downloads
                   • Volledig getrackte sites (cookies)



Wednesday 6 July 2011
Varnish extra’s

                   • Grace timeout
                   • Meerdere backends - loadbalancing / failover
                   • Specifieke, partial caching



Wednesday 6 July 2011
Uitrollen: dedicated

                   • Eenvoudige opzet - laag voor webserver
                   • Configuratie op maat
                   • Verregaande manipulaties mogelijk
                   • Op maat, contacteer ons


Wednesday 6 July 2011
Uitrollen: shared

                   • Algemene configuratie nodig
                   • Conservatieve configuratie
                   • Minimale manipulatie mogelijk
                   • Openminds biedt het aan


Wednesday 6 July 2011
Openminds varnish
                   • Beta
                   • Opt-in mechanisme
                   • Gezonde defaults
                   • IPv4 en IPv6
                   • Regels worden nog gecommuniceerd!


Wednesday 6 July 2011
Q&A



Wednesday 6 July 2011
Varnish voor
                        webbouwers
                          Openminds TechTalk
                             6 juli 2011

                          www.openminds.be
                        Managed hosting solutions
                         Twitter: @openminds



Wednesday 6 July 2011

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Techtalk Varnish

  • 1. Varnish voor webbouwers Openminds TechTalk 6 juli 2011 www.openminds.be Managed hosting solutions Wednesday 6 July 2011
  • 3. Varnish • Noorse tabloid Verdens Gang - 1.0 in 2006 - 3.0 enkele dagen terug • Snelheidswinst site: 10x - 300x • caching HTTP reverse proxy Wednesday 6 July 2011
  • 4. normaal Client Internetlijn Server Datacentrum Wednesday 6 July 2011
  • 5. klassieke proxy Trage Internetlijn Client Client Proxy Server Client Datacentrum Wednesday 6 July 2011
  • 6. reverse proxy Client Snelle lijnen Client Client Proxy Server Datacentrum Wednesday 6 July 2011
  • 7. reverse proxy Client Snelle lijnen Client Client Proxy Server Server Server Datacentrum Wednesday 6 July 2011
  • 8. caching reverse proxy Client Caching Client Client Server Server Proxy Server Datacentrum Wednesday 6 July 2011
  • 9. Waarom? • Serverbelasting omlaag • Veel snellere site-ervaring • Veel meer hits/s afwerken met zelfde hardware • Ademruimte voor serverhits Wednesday 6 July 2011
  • 11. Caching • Identieke aanvraag - identiek antwoord • We houden het volledige antwoord bij • Headers • Data (HTML) Wednesday 6 July 2011
  • 12. Identieke aanvraag Identiek antwoord Wednesday 6 July 2011
  • 13. Aanvraag GET / HTTP/1.1 Host: www.openminds.be User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en,en-us;q=0.7,nl-be;q=0.3 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive Cookie: __utma=121817557.1268321880.1308719392.1309764385.1309861948.8; __utmz=121817557.1308719392.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09 Og9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db25 0cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2Vkew Y7CFQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; __utmc=121817557; __utmb=121817557.2.10.1309861948 Wednesday 6 July 2011
  • 14. Aanvraag GET / HTTP/1.1 Host: www.openminds.be User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en,en-us;q=0.7,nl-be;q=0.3 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive Cookie: __utma=121817557.1268321880.1308719392.1309764385.1309861948.8; __utmz=121817557.1308719392.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09 Og9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db25 0cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2Vkew Y7CFQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; __utmc=121817557; __utmb=121817557.2.10.1309861948 Wednesday 6 July 2011
  • 15. Aanvraag • Host • URI (pad, method/verb, version) • Cookies • Encoding / compressie Wednesday 6 July 2011
  • 16. Antwoord HTTP/1.1 200 OK Server: nginx/0.5.32 Date: Tue, 05 Jul 2011 10:52:36 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15 Etag: "25ec477310b3f81f097d5f6f3b5824f6" X-Rack-Cache: stale, invalid, store X-Content-Digest: af41dfcde5cfeaa55717261890560d56595be969 X-Runtime: 2559 Cache-Control: max-age=300, public Age: 21 Set-Cookie: _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09O g9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db250c m9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2VkewY7C FQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; path=/; HttpOnly Content-Length: 11565 Status: 200 X-server: pro-005 X-Proxy: fosfor Wednesday 6 July 2011
  • 17. Wat cachen? • Statische content (images, css, js, ...) • Hoofdpagina’s / hoofdpaden • Zoveel mogelijk • Versie per variatie bijhouden (encoding...) • GET/HEAD Wednesday 6 July 2011
  • 19. Wat niet cachen • admin/management secties • pagina’s die zich aanpassen aan user (logged in, winkelmandje, profielen, ...) • 404 / 500 / ... • POST/PUT/DELETE Wednesday 6 July 2011
  • 20. Cookies • Sessie - antwoord niet cachen • Google - doet er op zich niet toe • Variaties - antwoord wel cachebaar Wednesday 6 July 2011
  • 21. Stel... • ... dat de webapplicatie dit meegeeft • browser-cache hints worden gestuurd • meestal fout Wednesday 6 July 2011
  • 22. Cache-Control HTTP/1.1 200 OK Server: nginx/0.5.32 Date: Tue, 05 Jul 2011 10:52:36 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.15 Etag: "25ec477310b3f81f097d5f6f3b5824f6" X-Rack-Cache: stale, invalid, store X-Content-Digest: af41dfcde5cfeaa55717261890560d56595be969 X-Runtime: 2559 Cache-Control: max-age=300, public Age: 21 Set-Cookie: _openminds_session=BAh7CToQX2NzcmZfdG9rZW4iMXBqNFJyS1RKRUxqNVpSNXBRb2R4N1RTN25GY1RSaVhKQVZscXR6alBqRU09O g9zZXNzaW9uX2lkIiU3YzEwNjI4YjQ2ODhmMGE4OWE2NTRhYjU2ZmU1NTgxNyIMdXNlcl9pZGkKIgpmbGFzaElDOidBY3Rpb25Db250c m9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGljZSIkWW91ciBwYWdlIGhhcyBiZWVuIHNhdmVkIGJlbG93LgY6CkB1c2VkewY7C FQ%3D--f8439d4c16ca7b72afebf9ae05f150700d6ee0e1; path=/; HttpOnly Content-Length: 11565 Status: 200 X-server: pro-005 X-Proxy: fosfor Wednesday 6 July 2011
  • 23. Cache hints • max-age - eenvoudig (HTTP 1.1) • expires - zeer specifiek (HTTP 1.0) • “pragma: no-cache” • etags • ... Wednesday 6 July 2011
  • 24. Varnish manipuleert • Zowel aanvraag als antwoord • Strippen, herzetten, ... van velden • Cookies manipuleren • Cache-timings Wednesday 6 July 2011
  • 25. Cache timings • De duur dat Varnish het zelf bijhoudt (varnish ttl) - bvb 24 uur • De duur dat een client het mag bijhouden (browser cache) - bvb 2 uur of 30 dagen Wednesday 6 July 2011
  • 26. Een voorbeeld • Gewone, publieke site • Rails-applicatie met eigen CMS • Eenvoudige VDS • 100Mbps • Eenvoudige varnish config (cache-control was correct) Wednesday 6 July 2011
  • 28. 1 second cache • Pollers • 100 tot 10000 polls per seconde • +/- timestamp terugsturen • zorgt voor 99 tot 9999 minder hits/s Wednesday 6 July 2011
  • 30. Images • Hard forceren • Alle cookies strippen • Hogere cache-control zetten Wednesday 6 July 2011
  • 31. Talen • Taal niet opslaan in sessie • Taal in cookie opslaan (language=nl) • Wordt een variatie voor Varnish • Homepagina voor Nederlands • Homepagina voor Frans Wednesday 6 July 2011
  • 32. Anonieme cookies • Drupal 6 • Symfony • CakePHP • Rails • ... Wednesday 6 July 2011
  • 33. Admin interfaces • Volledig namespaced (/admin/...) • Andere url (admin.openminds.be) • Sessie-cookie verwijderen bij logout Wednesday 6 July 2011
  • 34. Logged in users • Moeilijk! • Assets op andere hosts/url • Ajax ? • Partial caching van Varnish (advanced) Wednesday 6 July 2011
  • 35. There are only two hard things in Computer Science: cache invalidation and naming things — Phil Karlton Wednesday 6 July 2011
  • 36. Cache invalidation • Wat bij edit/put/post/... • eenvoudig: PURGE op juiste URL(s) • control channel • Drupal module • Lacquer gem • Purged de browser niet !!! Wednesday 6 July 2011
  • 37. Webbouwers • Anonieme cookies nodig? • Admin sectie duidelijk • Variaties aantoonbaar (language-cookie bv) • Cache-control headers zijn belangrijk • Vooraf over nadenken Wednesday 6 July 2011
  • 38. Kleine sites • Snelheid omhoog • Zijn meestal zeer statisch • Code mag zelfs iets minder performant dan • Purge kan volledig zijn Wednesday 6 July 2011
  • 39. Grote projecten • Performantie • Beschikbaarheid • Kosten drukken (minder hardware) • Cache invalidation belangrijk Wednesday 6 July 2011
  • 40. Opletten voor... • User-agent voor Mobile Device detection • Captcha (cookies voor images?) • X-Forwarded-For Wednesday 6 July 2011
  • 41. Varnish niet voor • Grote downloads • Volledig getrackte sites (cookies) Wednesday 6 July 2011
  • 42. Varnish extra’s • Grace timeout • Meerdere backends - loadbalancing / failover • Specifieke, partial caching Wednesday 6 July 2011
  • 43. Uitrollen: dedicated • Eenvoudige opzet - laag voor webserver • Configuratie op maat • Verregaande manipulaties mogelijk • Op maat, contacteer ons Wednesday 6 July 2011
  • 44. Uitrollen: shared • Algemene configuratie nodig • Conservatieve configuratie • Minimale manipulatie mogelijk • Openminds biedt het aan Wednesday 6 July 2011
  • 45. Openminds varnish • Beta • Opt-in mechanisme • Gezonde defaults • IPv4 en IPv6 • Regels worden nog gecommuniceerd! Wednesday 6 July 2011
  • 47. Varnish voor webbouwers Openminds TechTalk 6 juli 2011 www.openminds.be Managed hosting solutions Twitter: @openminds Wednesday 6 July 2011