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
350
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
Qiita埋め込み用スライド
naoki_0531
0
5.1k
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
290
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
540
マイクロサービスにおける容易なトランザクション管理に向けて
scalar
0
140
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
170
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
560
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
200
複雑性の高いオブジェクト編集に向き合う: プラガブルなReactフォーム設計
righttouch
PRO
0
120
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
100
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Building Your Own Lightsaber
phodgson
103
6.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Code Review Best Practice
trishagee
65
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Making the Leap to Tech Lead
cromwellryan
133
9k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Being A Developer After 40
akosma
87
590k
What's in a price? How to price your products and services
michaelherold
243
12k
How to train your dragon (web standard)
notwaldorf
88
5.7k
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