(Surge 2014) This is a longer version of our Velocity 2014 slides around caching dynamic content. Topic: In the past, CDNs have been used to cache and distribute static objects. But issues around invalidation, staleness, and lack of visibility have prevented us from using CDNs to fully leverage the benefits of caching when it comes to dynamic content. Today, using a real-time, modern CDN that provides instant cache invalidation and real-time analytics allows for instantaneous control over dynamic content caching.
3. 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
8. 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…
19. 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
22. 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
23. 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
30. So
Many
Benefits!
• Performance
– Faster
+me
to
first
byte
– Faster
start
render
– Happy
users!
• Offload
– Less
work
for
our
servers
– Less
bandwidth
at
origin
33. 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
34. Instant?
• IS
NOT:
– 12
minutes!
– quick
acknowledgment!
• IS:
– <1sec
– predictable
and
determinis+c
behavior
– (has
to
also
include
propaga+on)
35. Power
of
the
Purge!
• Purge
dependencies
– Surrogate
Keys
– Using
tags/labels
to
purge
en+re
chunks
of
content
at
once
79. 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
98. 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
100. 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!