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
90
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
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
Lambdaと地方とコミュニティ
miu_crescent
2
370
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
170
Platform Engineering for Software Developers and Architects
syntasso
1
520
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Gamification - CAS2011
davidbonilla
80
5k
Practical Orchestrator
shlominoach
186
10k
Building an army of robots
kneath
302
43k
GraphQLとの向き合い方2022年版
quramy
43
13k
RailsConf 2023
tenderlove
29
900
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Into the Great Unknown - MozCon
thekraken
32
1.5k
GitHub's CSS Performance
jonrohan
1030
460k
Six Lessons from altMBA
skipperchong
27
3.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
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