Download - Caching the Uncacheable [Long Version]
![Page 1: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/1.jpg)
Caching The Uncacheable
Leveraging Your CDN To Cache Dynamic Content
Hooman Behesh+, VP Technology
![Page 2: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/2.jpg)
Dynamic Content Is Really Interes<ng!
![Page 3: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/3.jpg)
What Is Dynamic Content?
• Stuff that’s not sta+c! • With web traffic, generally the base HTML – Big deal because it’s blocking – And some+mes a large object à longer download
![Page 4: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/4.jpg)
![Page 5: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/5.jpg)
Blocking
![Page 6: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/6.jpg)
![Page 7: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/7.jpg)
![Page 8: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/8.jpg)
What Is Dynamic Content? • Stuff that’s not sta+c! • With web traffic, generally the base HTML – Big deal because it’s blocking – And some+mes a large object à longer download
• Could be other things too – AJAX calls – API calls
• More…
![Page 9: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/9.jpg)
Classically, with dynamic content…
Caching
![Page 10: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/10.jpg)
Dynamic Content Caching Problems
• Serving stale pages – Lack of good invalida+on framework
![Page 11: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/11.jpg)
Caching vs.
Invalida<on
![Page 12: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/12.jpg)
![Page 13: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/13.jpg)
![Page 14: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/14.jpg)
![Page 15: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/15.jpg)
We tried…
![Page 16: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/16.jpg)
Dynamic Content Caching Problems
• Serving stale pages – Lack of good invalida+on framework
![Page 17: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/17.jpg)
Dynamic Content Caching Problems
• Serving stale pages – Lack of good invalida+on framework
• Real-‐+me visibility – Real-‐+me analy+cs/stats – Real-‐+me logging/tracking
![Page 18: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/18.jpg)
So…
Caching
![Page 19: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/19.jpg)
CDNs and Dynamic Content
• Generally, handling dynamic content has been a maRer of transport – Op+mize from-‐origin delivery – “DSA” (Dynamic Site Accelera+on) – Middle mile op+miza+ons – TCP tweaks
![Page 20: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/20.jpg)
Dynamic Content, Tradi<onally
CDN Node
Client
Origin
Some TCP Tweaks
![Page 21: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/21.jpg)
Dynamic Content, Tradi<onally
CDN Node CDN Node
Client
Origin
Lots of TCP Tweaks
![Page 22: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/22.jpg)
Dynamic Content, Tradi<onally
• We some+mes do micro caching of HTML – Short TTL for HTML content via Cache-‐Control – Not full proof
• Ex: news stories faux-‐pas!
• ESI (Edge Side Includes) – Par+al caching – Hard and onerous
![Page 23: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/23.jpg)
Actually…
• Dynamic content is more cacheable than we think
• Sta+c for shorter periods of +me
• Unpredictable invalida+on – Standard HTTP caching rules aren’t good enough
![Page 24: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/24.jpg)
A Lot BeLer!
CDN Node CDN Node
Client
Origin
![Page 25: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/25.jpg)
No CDN
![Page 26: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/26.jpg)
CDN (sta<c)
![Page 27: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/27.jpg)
Blocking CDN
(sta<c)
![Page 28: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/28.jpg)
CDN (sta<c)
![Page 29: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/29.jpg)
CDN (sta<c
+ dynamic)
![Page 30: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/30.jpg)
So Many Benefits!
• Performance – Faster +me to first byte – Faster start render – Happy users!
• Offload – Less work for our servers – Less bandwidth at origin
![Page 31: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/31.jpg)
What would make it beLer?
![Page 32: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/32.jpg)
Programma<c Invalida<on
• Invalida+on API
• Granular – Specific URL – URL groups – All – Etc…
![Page 33: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/33.jpg)
Purge • As a page gets published/updated, a purge command also gets published
• Must be Instant!
• Big problem with classic CDNs – mul+-‐minute purges! – Ex: News story, part 2
![Page 34: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/34.jpg)
Instant?
• IS NOT: – 12 minutes! – quick acknowledgment!
• IS: – <1sec – predictable and determinis+c behavior – (has to also include propaga+on)
![Page 35: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/35.jpg)
Power of the Purge!
• Purge dependencies – Surrogate Keys – Using tags/labels to purge en+re chunks of content at once
![Page 36: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/36.jpg)
Not totally obsolete!
![Page 37: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/37.jpg)
Example: CMS + Purge
![Page 38: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/38.jpg)
WordPress: Before
CDN Node
![Page 39: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/39.jpg)
WordPress: Before
CDN Node
![Page 40: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/40.jpg)
WordPress: Before
CDN Node
![Page 41: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/41.jpg)
WordPress: Before
CDN Node
![Page 42: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/42.jpg)
WordPress: Before
CDN Node
Cache
![Page 43: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/43.jpg)
![Page 44: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/44.jpg)
WordPress: AVer
CDN Node
![Page 45: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/45.jpg)
WordPress: AVer
CDN Node
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 55,666Cache-Control: Totally Long Time!
![Page 46: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/46.jpg)
WordPress: AVer
CDN Node
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 55,666Cache-Control: Totally Long Time!
![Page 47: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/47.jpg)
WordPress: AVer
CDN Node
![Page 48: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/48.jpg)
WordPress: AVer
CDN Node
![Page 49: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/49.jpg)
WordPress: AVer
CDN Node PURGE
![Page 50: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/50.jpg)
WordPress: AVer
CDN Node PURGE
![Page 51: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/51.jpg)
WordPress: AVer
CDN Node
(Has to be instantaneous!)
PURGE
![Page 52: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/52.jpg)
WordPress: AVer
CDN Node
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 55,666Cache-Control: Totally Long Time!
![Page 53: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/53.jpg)
WordPress: AVer
CDN Node
![Page 54: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/54.jpg)
Example: customer1.js
![Page 55: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/55.jpg)
Before
CDN Node
Origin http://www.3rdparty.com/customer1.js
(Referer: www.customer1.com)
![Page 56: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/56.jpg)
Before
CDN Node
Origin http://www.3rdparty.com/customer1.js
![Page 57: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/57.jpg)
Before
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
![Page 58: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/58.jpg)
Before
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
![Page 59: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/59.jpg)
Before
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
![Page 60: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/60.jpg)
Before
CDN Node
Origin http://www.3rdparty.com/customer1.js
(Ager 1 min)
![Page 61: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/61.jpg)
Before
CDN Node
Origin http://www.3rdparty.com/customer1.js VALIDATION
If-Modified-Since: Wed, 24 Sep 2014 19:51:30 GMT
(Ager 1 min)
![Page 62: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/62.jpg)
Before
CDN Node
Origin http://www.3rdparty.com/customer1.js
304 Not Modified
(Ager 1 min)
![Page 63: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/63.jpg)
Before
CDN Node
Origin http://www.3rdparty.com/customer1.js
304 Not Modified
(Ager 1 min)
![Page 64: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/64.jpg)
AVer
CDN Node
Origin http://www.3rdparty.com/customer1.js
![Page 65: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/65.jpg)
AVer
CDN Node
Origin http://www.3rdparty.com/customer1.js
![Page 66: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/66.jpg)
AVer
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60, s-maxage=2592000Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
![Page 67: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/67.jpg)
AVer
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60, s-maxage=2592000Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
![Page 68: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/68.jpg)
AVer
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60, s-maxage=2592000Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
![Page 69: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/69.jpg)
AVer
CDN Node
Origin http://www.3rdparty.com/customer1.js
(Ager 1 min)
![Page 70: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/70.jpg)
AVer
CDN Node
Origin http://www.3rdparty.com/customer1.js
(Ager 1 min)
![Page 71: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/71.jpg)
This happens many many <mes! (many many happy visitors!)
![Page 72: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/72.jpg)
AVer
CDN Node
Origin
Customer1 changes config
(Ager 1 min)
![Page 73: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/73.jpg)
AVer
CDN Node
Origin PURGE customer1.js
Customer1 changes config
(Ager 1 min)
![Page 74: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/74.jpg)
AVer
CDN Node
Origin PURGE customer1.js
Customer1 changes config
(Ager 1 min)
![Page 75: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/75.jpg)
AVer
CDN Node
Origin http://www.3rdparty.com/customer1.js
(Ager 1 min)
![Page 76: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/76.jpg)
AVer
CDN Node
Origin http://www.3rdparty.com/customer1.js
HTTP/1.1 200 OKCache-Control: max-age=60, s-maxage=2592000Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
(Ager 1 min)
![Page 77: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/77.jpg)
AVer
CDN Node
Origin
HTTP/1.1 200 OKCache-Control: max-age=60, s-maxage=2592000Last-Modified: Wed, 24 Sep 2014 19:51:30 GMTContent-Type: application/javascriptDate: Thu, 25 Sep 2014 12:22:20 GMTServer: ApacheContent-Length: 7835
http://www.3rdparty.com/customer1.js
(Ager 1 min)
![Page 78: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/78.jpg)
More than just Invalida<on…
![Page 79: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/79.jpg)
The Influence of Clouds
• The CDN is an extension of the app • No longer a black box • Real-‐+me integra+on with the app • Infrastructure as code – Your content => You need control
![Page 80: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/80.jpg)
Control
• Programmability – Configura+on API – Invalida+on API – Instantaneous and real +me
![Page 81: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/81.jpg)
Caching Control
• Granular caching – Dynamic caching – flexible cache keys – etc
• Ex: Geo-‐based caching
![Page 82: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/82.jpg)
Control at the Edge
• Moving app logic to the edge • VCL – Varnish Configura+on Language – Script-‐like configura+on for func+onality at the edge
![Page 83: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/83.jpg)
Visibility
• Real +me analy+cs – Network stats – HTTP stats (status codes , etc) – Caching stats (hits, misses, etc) – Stats API
• Logging – Real +me logs – Streaming to various log des+na+ons
![Page 84: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/84.jpg)
Example: Beacon Termina<on at the Edge
![Page 85: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/85.jpg)
Before
CDN Node
Origin
Log Analysis
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 86: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/86.jpg)
Before
CDN Node
Origin
Log Analysis
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 87: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/87.jpg)
Before
CDN Node
Origin
Log Analysis
HTTP/1.1 200 OKPragma: no-cacheExpires: Wed, 19 Apr 2000 11:43:00 GMTCache-Control: no-cache, no-storeLast-Modified: Wed, 21 Jan 2004 19:51:30 GMTContent-Type: image/gifDate: Fri, 20 Jun 2014 12:22:20 GMTServer: ApacheContent-Length: 35
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 88: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/88.jpg)
Before
CDN Node
Origin
Log Analysis
HTTP/1.1 200 OKPragma: no-cacheExpires: Wed, 19 Apr 2000 11:43:00 GMTCache-Control: no-cache, no-storeLast-Modified: Wed, 21 Jan 2004 19:51:30 GMTContent-Type: image/gifDate: Fri, 20 Jun 2014 12:22:20 GMTServer: ApacheContent-Length: 35
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 89: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/89.jpg)
AVer
CDN Node
Origin http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 90: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/90.jpg)
AVer
CDN Node
Origin
HTTP/1.1 200 OKPragma: no-cacheExpires: Wed, 19 Apr 2000 11:43:00 GMTCache-Control: no-cache, no-storeLast-Modified: Wed, 21 Jan 2004 19:51:30 GMTContent-Type: image/gifDate: Fri, 20 Jun 2014 12:22:20 GMTServer: ApacheContent-Length: 35
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 91: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/91.jpg)
AVer
CDN Node
Origin
HTTP/1.1 204 No ContentDate: Sat, 21 Jun 2014 23:21:12 GMTServer: Awesome ServerContent-Length: 0
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 92: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/92.jpg)
AVer
CDN Node
Origin
Syslog / S3 / FTP/etc
http://collector.site.com/beacon.img?a=1&b=2&c=3
![Page 93: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/93.jpg)
Example: Edge-‐generated Content
![Page 94: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/94.jpg)
JSON Data Center ID
CDN Node
Origin http://www.site.com/which_datacenter.js
![Page 95: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/95.jpg)
JSON Data Center ID
CDN Node
Origin
{ ‘datacenter’ : ‘SJC’ }
http://www.site.com/which_datacenter.js
![Page 96: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/96.jpg)
VCL Snippet
![Page 97: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/97.jpg)
JSON Geo IP
CDN Node
Origin
{ “city” : “New York”, “state”: “New York”, “country”: “United States”, “ip”: “173.18.14.237”}
http://www.site.com/geo_ip.js
![Page 98: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/98.jpg)
More Examples
• Caching with tracking cookies: – hRp://www.fastly.com/blog/how-‐to-‐cache-‐with-‐tracking-‐cookies
• API Caching: – hRp://www.fastly.com/blog/api-‐caching-‐part-‐iii (part 3, with links to previous two parts)
• Log Streaming: – hRp://www.fastly.com/blog/+ps-‐for-‐streaming-‐logs
![Page 99: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/99.jpg)
Let’s Sum Up!
![Page 100: Caching the Uncacheable [Long Version]](https://reader034.vdocuments.us/reader034/viewer/2022042813/547e89dcb47959a7508b4bdd/html5/thumbnails/100.jpg)
Summary
• Dynamic content can be cached – We need instant purging – We need real-‐+me logs and stats
• Real-‐+me integra+on of our CDN with our app is cool! – Extensive/granular API to control the CDN – Control and visibility at the edge lets us be really crea+ve
• Never use “Totally Long Time!” in a Cache-Control header!