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
550
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
680
DrupalCamp Ghent 2012
wonko
1
590
Basic Deployment techtalk
wonko
5
790
Other Decks in Technology
See All in Technology
なぜ私は自分が使わないサービスを作るのか? / Why would I create a service that I would not use?
aiandrox
0
810
表現を育てる
kiyou77
1
220
全文検索+セマンティックランカー+LLMの自然文検索サ−ビスで得られた知見
segavvy
2
120
2.5Dモデルのすべて
yu4u
2
900
JEDAI Meetup! Databricks AI/BI概要
databricksjapan
0
230
スタートアップ1人目QAエンジニアが QAチームを立ち上げ、“個”からチーム、 そして“組織”に成長するまで / How to set up QA team at reiwatravel
mii3king
2
1.8k
白金鉱業Meetup Vol.17_あるデータサイエンティストのデータマネジメントとの向き合い方
brainpadpr
7
850
AI エージェント開発を支える MaaS としての Azure AI Foundry
ryohtaka
6
610
Culture Deck
optfit
0
430
SA Night #2 FinatextのSA思想/SA Night #2 Finatext session
satoshiimai
1
150
Autonomous Database Serverless 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
17
45k
The Future of SEO: The Impact of AI on Search
badams
0
220
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
298
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Automating Front-end Workflow
addyosmani
1368
200k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
How GitHub (no longer) Works
holman
314
140k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Statistics for Hackers
jakevdp
797
220k
Building Applications with DynamoDB
mza
93
6.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