Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Varnish
Search
Bernard Grymonpon
November 05, 2013
Technology
0
91
Varnish
Varnish techtalk november 2013
Bernard Grymonpon
November 05, 2013
Tweet
Share
More Decks by Bernard Grymonpon
See All by Bernard Grymonpon
Techtalk: beveiligde verbindingen
wonko
0
450
MySQL techtalk
wonko
0
540
Metrics & Dashboards
wonko
0
420
Vagrant en Sneakers
wonko
0
560
Techtalk: DNS & domeinen
wonko
1
290
Arrrrcamp 2012: Testing Chef
wonko
1
360
New Relic Techtalk
wonko
1
670
DrupalCamp Ghent 2012
wonko
1
590
Basic Deployment techtalk
wonko
5
790
Other Decks in Technology
See All in Technology
あなたの人生も変わるかも?AWS認定2つで始まったウソみたいな話
iwamot
3
880
FODにおけるホーム画面編成のレコメンド
watarukudo
PRO
2
380
色々なAWSサービス名の由来を調べてみた
iriikeita
0
120
comilioとCloudflare、そして未来へと向けて
oliver_diary
6
470
トラブルシュートを楽しもう (wakamonog meeting 15)
recuraki
3
690
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
2k
三菱電機で社内コミュニティを立ち上げた話
kurebayashi
1
370
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
デジタルアイデンティティ技術 認可・ID連携・認証 応用 / 20250114-OIDF-J-EduWG-TechSWG
oidfj
2
720
今年一年で頑張ること / What I will do my best this year
pauli
1
230
20250122_FinJAWS
takuyay0ne
2
140
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
250
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
244
12k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
580
Six Lessons from altMBA
skipperchong
27
3.6k
A Tale of Four Properties
chriscoyier
157
23k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Gamification - CAS2011
davidbonilla
80
5.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Producing Creativity
orderedlist
PRO
343
39k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Transcript
Varnish Openminds Techtalk - 5 & 7 november 2013 Friday
17 January 14
Friday 17 January 14
Normaal Client Server Request Response Friday 17 January 14
Normaal Client Server Request Response Client Request Response Friday 17
January 14
Caching Client Server Req A Resp A Client Req A
Resp A V a r n i s h Req A Resp A Friday 17 January 14
Request Friday 17 January 14
GET /nl HTTP/1.1 Host: www.openminds.be Connection: keep-alive Accept: text/html,applic...age/webp,*/*;q=0.8 User-Agent:
Mozil...ari/537.36 Referer: http://www.openminds.be/nl Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Cookie: ag9...mcmd=email Friday 17 January 14
GET /nl HTTP/1.1 Host: www.openminds.be Connection: keep-alive Accept: text/html,applic...age/webp,*/*;q=0.8 User-Agent:
Mozil...ari/537.36 Referer: http://www.openminds.be/nl Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Cookie: ag9...mcmd=email Friday 17 January 14
Gelijke aanvragen • Verb • URL • Cookies Friday 17
January 14
Response Friday 17 January 14
HTTP/1.1 200 OK Server: nginx/1.2.7 Content-Type: text/html;charset=utf-8 X-Powered-By: PHP/5.4.12-1~dotdeb.1 Pragma:
no-cache Content-Encoding: gzip Set-Cookie: frontend_language=s:2:"nl";; expires=Fri, 01-Apr-2016 07:00:00 GMT; path=/; domain=.openminds.be X-step: nl cache-control: max-age = 600 Content-Length: 6155 Date: Tue, 05 Nov 2013 07:29:17 GMT Vary: Accept-Language Connection: close Friday 17 January 14
HTTP/1.1 200 OK Server: nginx/1.2.7 Content-Type: text/html;charset=utf-8 X-Powered-By: PHP/5.4.12-1~dotdeb.1 Pragma:
no-cache Content-Encoding: gzip Set-Cookie: frontend_...n=.openminds.be X-step: nl cache-control: max-age = 600 Content-Length: 6155 Date: Tue, 05 Nov 2013 07:29:17 GMT Vary: Accept-Language Connection: close Friday 17 January 14
HTTP/1.1 200 OK Server: nginx/1.2.7 Content-Type: text/html;charset=utf-8 X-Powered-By: PHP/5.4.12-1~dotdeb.1 Pragma:
no-cache Content-Encoding: gzip Set-Cookie: frontend_...n=.openminds.be X-step: nl cache-control: max-age = 600 Content-Length: 6155 Date: Tue, 05 Nov 2013 07:29:17 GMT Vary: Accept-Language Connection: close Friday 17 January 14
Wanneer cachen? • Gelijke requests • Server geeft aan dat
er gecached mag worden Friday 17 January 14
TTL you say? • Time to live • Default: 120
seconden • Override door Cache-control of Expires Friday 17 January 14
Cache-control • Max-age & S-maxage (in seconden) • Public &
Private • No-cache / No-store • Must-revalidate / Proxy-revalidate Friday 17 January 14
Expires • Ondergeschikt aan cache-control • Geeft aan wanneer het
object niet meer geldig is Expires:Thu, 14 Nov 2013 16:06:33 GMT Friday 17 January 14
Age • Leeftijd van de content • Cache-laag kan dit
meegeven • Echte levensduur: max-age min age (of s-maxage - age) Friday 17 January 14
Vary • Response (server -> client) • Geeft aan waarin
de pagina kan verschillen • Hint voor cache-laag • Vary: Cookie, Accept-Encoding Friday 17 January 14
Vary • Vary: * -> niet cachebaar • Geen Cookie=language
• Slechte header - logica moet meestal in VCL Friday 17 January 14
Werking varnish • Goede samenwerking tussen app en varnish •
Goed opletten! Friday 17 January 14
Config • Frontend (web & control) • Backend(s) (meerdere mogelijk)
• Settings (threads,... parameters) • Logica (VCL - C-achtig) Friday 17 January 14
Vereenvoudigde flow Friday 17 January 14
Objecten • req (req.http.cookie, req.url, req.host) • beresp (beresp.http.set-cookie, ...)
• Friday 17 January 14
Volledige flow https://www.varnish-software.com/static/book/_images/ vcl.png https://www.varnish-cache.org/trac/wiki/ VCLExampleDefault Friday 17 January 14
Wanneer cacht varnish? • GET en HEAD, geen auth en
geen cookies, • Hashing op basis van IP/host + url • Vary * en Set-Cookie zijn ook a nappers Friday 17 January 14
Hoelang cachen? • Wat als mijn inhoud wijzigt? • Ban’s
Friday 17 January 14
Control channel • varnishadm • Socket, poort 6082 • ban.list,
ban.url, ban.req ... • plugins/gems/modules/... Friday 17 January 14
ban ban req.url ~ "/foo" ban req.http.host ~ "example.com" &&
obj.http.content-type ~ "text" Friday 17 January 14
Specifieke ban • Hashing aanpassen -> meer om op te
bannen • Ban lurker Friday 17 January 14
Ban lurker • Geen toegang tot req (req.host en req.url)
• Enkel toegang tot obj set beresp.http.x-url = req.url; set beresp.http.x-host = req.http.host; ban obj.http.x-url ~ /something/ Friday 17 January 14
Cookies • Session cookies (SESS=...) • Specifieke cookies (language=...) •
Client-side cookies (has_js, _utmc...) Friday 17 January 14
Client-side cookies • Enkel nuttig bij de client • Kunnen
genegeerd worden • has_js, _umtc, ... Friday 17 January 14
Session cookies • Niet cachebaar • Inhoud op server •
Heb je die echt nodig? Friday 17 January 14
Specifieke Cookies • Specifieke cookies • Geeft variatie aan (taal
bvb) • Prima bruikbaar Friday 17 January 14
Voorbeelden Friday 17 January 14
Esi Friday 17 January 14
ESI • Edge Side Includes • http://www.w3.org/TR/edge-arch • Surrogate-Capability header
(P->S) • Surrogate-Control (S->P) Friday 17 January 14
Edge Side Includes • Niet elk deel van de pagina
even lang cachen • Een deel niet cachen Main Overview List Cart Friday 17 January 14
Edge Side Includes • Niet elk deel van de pagina
even lang cachen • Een deel niet cachen 1 uur 5 min 30 sec 0 sec Friday 17 January 14
Esi: technisch • Varnish: do-esi • Headers of vaste config
• Esi in Esi? Friday 17 January 14
sub vcl_recv { set req.http.Surrogate-Capability="key=ESI/1.0"; } sub vcl_fetch { if
(beresp.http.Surrogate-Control ~ "ESI/1.0") { set beresp.do_esi = true; } } Friday 17 January 14
Voorbeeld • <esi:include src=”/cart/content” /> • GET /cart/content -> server
• Wat terugkeert komt in de pagina Friday 17 January 14
X-Forwarded-For • Chain van alle clients • X-Forwarded-Proto Friday 17
January 14
Caching • Veel aangepaste data? (Nieuwssite) • Ingelogde gebruikers? (Community)
• Form submits? (Wedstrijden) • Verschillende pagina’s per visitor? (Mobile vs Desktop vs Tablet) Friday 17 January 14
Ideale wereld: site • 1 uur cache? eindeloze cache? •
Browser cache niet nodig • Bij admin aktie: ban • Geen ingelogde gebruikers • Talen/... via cookie Friday 17 January 14
IW: Nieuwssite • Eindeloze cache • Browser-cache • Bans bij
updates • Client-side cookies voor “favorieten” • ESI voor inlog? Friday 17 January 14
Community • Login/Welcome-blok in ESI • Javascript update rest van
pagina • Cache op user-objecten • Partial caching op content-items Friday 17 January 14
Webshop • Catalogus items gecached • ESI of Ajax voor
opbouw (endless scroll?) • Winkelmandje in client-cache • Pas bij checkout: sessie • Laatst bekeken: client-side Friday 17 January 14