This talk is anecdotal about the story of YouTube Feather, the woes of browser caching, the effects of HTML5 Unicorns, and the undying love for all things kitten videos.
Given at http://www.jseverywhere.org/ on October 25, 2013 in San Francisco by Matthew Keas.
http://mkeas.org
http://twitter.com/matthiasak
5. "one of the senior engineers began a rant about the
page weight of the video watch page being far too
large"
6. "1.2MB and dozens of requests"
"if they can write an entire Quake clone in under
100KB, we have no excuse for this!"
7. "After three painstaking days, I had arrived at a much leaner
solution. It still was not under 100KB though. Having just
finished writing the HTML5 video player, I decided to plug it
in instead of the far heavier Flash player. Bam! 98KB and
only 14 requests."
tiny
HTML
8. "I decided to limit the functionality"
masthead
video player
five related videos
sharing button
flagging tool
ten comments loaded in via AJAX
remedy?
9. "After a week of data collection, the numbers came back…
and they were baffling. The average aggregate page latency
under Feather had actually INCREASED"
HALLOWEEN
Party
10. "We plotted the data geographically and compared it to our total
numbers broken out by region"
hello!
howdy!
YOUTUBE
. YES!!
11. Southeast Asia
A m e ri c a
South
OPEN
Come in,
Re
m
ot
e
Si
be
ri a
WE’RE
A
ca
ri
f
12. Average page load time under Feather was over TWO
MINUTES!
50
POSTAGE
STAMP
Normal page would take over 20 minutes.
13. "By keeping your client side code small and
lightweight, you can literally open your product up
to new markets."
ADDING
MATT'ISM
Improve you experience and broaden your reach
with:
• Fewer requests per page load
• Smaller requests per page load
• Less frequent requests per page load
14. ADDING
MATT'ISM
Improve you experience and broaden your reach
with:
• Fewer requests per page load (inlining, base64
encoding)
• Smaller requests per page load (concatenation,
compression, minification)
• Less frequent requests per page load (caching)
16. Methods of Caching?
Implied persistence
HTML <meta> tags
(http://www.mnot.net/cache_docs/)
HTTP Headers
(http://www.mobify.com/blog/beginners-guideto-http-cache-headers/)
Persist data via cookies...
Appcache
JavaScript?
23
ADMIT
NONE
17
17. HTML <meta> tags
Meta tags are easy to use, but aren’t very effective.
That’s because they’re only honored by a few
browser caches, not proxy caches (which almost
never read the HTML in the document).
19. HTML5 Appcache
(http://caniuse.com/#search=appcache
)
No support IE9- (trolololollllll)
Offline browsing - users can navigate your full site
when they're offline. (good)
Speed - cached resources are local, and therefore
load faster. (good)
Reduced server load (good)
Pretty Sexy
21. Más Problemas
http://appcachefacts.info
/
One failed file in CACHE section => entire cache
disregarded.
Regardless of whether you include the address
of the current page in the manifest, it will be
cached.
In Firefox, any resources served with Cachecontrol: no-store will not be cached, even if
they're explicitly included in the manifest.
No granular dynamic control from JS.
:–(
22. Is using JS to manage your cache
reasonable?
Yes. (http://caniuse.com/#feat=namevalue-storage)
If you need to support IE7 or Opera Mobile, then
employ HTTP Headers and/or just load resources
lazily.
Also, polyfills.
IE8 implemented this?
Wow.
23. Is this an original idea?
Sort of.
Anal
y
tics
28. Broke-al Storage
String values only — serialization may be
necessary (awkward)
Unstructured data with no transactions, indexing
or searching facilities (awkward)
May exhibit poor performance on large datasets
(bad)
30. Loading Browser Assets
CORS compatible or Same Origin? AJAX in
parallel, cache, and execute/embed sequentially.
Not Same Origin? Add Script/Link and set the
src/href.
31. Loading Browser Assets
Promises to control flow of async downloads and
"readystates".
Small abstraction for making a GET
Small functions to write tags to the <HEAD>
Tiny abstraction for Local Storage and error
handling
Automatically look for files to load (in similar
fashion to Require.js)