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
86
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
410
Vagrant en Sneakers
wonko
0
550
Techtalk: DNS & domeinen
wonko
1
280
Arrrrcamp 2012: Testing Chef
wonko
1
310
New Relic Techtalk
wonko
1
650
DrupalCamp Ghent 2012
wonko
1
580
Basic Deployment techtalk
wonko
5
790
Other Decks in Technology
See All in Technology
障害対応をちょっとずつよくしていくための 演習の作りかた
heleeen
0
150
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
120
Java EE/Jakarta EEの現状と将来―クラウドネイティブ時代にJava EEは対応できるのか?―
takakiyo
1
150
Next'24 事例セッションの紹介とクラウド資格を活用したキャリア形成について語りMuscle
yasumuusan
1
440
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
2.1k
DevOpsDays History and my DevOps story
kawaguti
PRO
9
2.5k
[新卒向け研修資料] テスト文字列に「うんこ」と入れるな(2024年版)
infiniteloop_inc
4
13k
データベース02: データベースの概念
trycycle
0
150
VSCodeの拡張機能を作っている話
ebarakazuhiro
1
370
Meta Quest 3 で動く桜マシマシ WebXR アプリを IBM Cloud Code Engine と Babylon.js で作った話
1ftseabass
PRO
0
120
一生覚えておきたい「システム開発=コミュニケーション」〜初めての実務案件振り返りLT〜
maimyyym
0
130
自己改善からチームを動かす! 「セルフエンジニアリングマネージャー」のすゝめ
shoota
6
430
Featured
See All Featured
Designing Experiences People Love
moore
136
23k
Designing for humans not robots
tammielis
248
25k
A designer walks into a library…
pauljervisheath
200
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
The Pragmatic Product Professional
lauravandoore
25
5.8k
Atom: Resistance is Futile
akmur
259
25k
Docker and Python
trallard
34
2.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
125
32k
We Have a Design System, Now What?
morganepeng
43
6.7k
A Modern Web Designer's Workflow
chriscoyier
689
190k
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