2. Mobile browsers are
dog slow
Only if they are used to render web
sites designed for desktop browsers.
One code for any browser and
device is actually a dream.
Bad code tends to have more impact
on mobile browsers.
3. Radio networks are
slow
The main issue is not speed but
latency.
4 Mb downloaded over a single
request: 2 seconds.
Same data downloaded as 20 small
files: 8 seconds.
4. A 304 reply code is nearly as bad as
a 200
404 replies are rarely cached. Kill
them all.
Proper caching of anything cacheable
is required
Don't overestimate the browser cache
and HTTP keep-alive.
5. HTML5 cache
manifest
Doesn't bring much over proper HTTP caching
for online apps.
Everything in the manifest is preloaded even
when useless for the current page. Double-
sided sword.
Requests from a cached page have no referrer.
No granularity: everything depends on the
freshness of the manifest.
6. Mobile browsers have
unpredicable caching
strategy
Even on the same operating system
iOS 4.1 on iPhone 3G doesn't cache
some tiny content that could really
be cached. And that the same OS on
other devices does.
8. Slower may feel
faster
Mobile devices have small screens.
Load visible content first, and use XHR to
load the rest.
Don't wait until the user scrolls, though.
Latency + tendency to scroll and zoom on
mobile devices would make the page feel
slow.
Provide feedback.
9. JS + HTTP caching
= not so bad
Don't repeat yourself: use static JS to
render common, static fragments.
Use XHR to render dynamic parts that
are not immediately visible.
Different parts can have different
expiration.
10. HTTP cache is quite
unpredictable
No control over actual eviction.
Might feel good, even for large
requests, until everything is evicted.
The server controls the cache, not
the client (which could come in
handy to avoid inconsistencies).
11. Localstorage is the
real shit
Seamlessly keeps over 2.5 Mb of data
per domain.
Mostly persistent.
Provides a flexible client-controlled
cache for any resource.
Trivial to implement.
13. Client-side
fragment caching
Dramatically improves performance of a
non-AJAXified page with minor changes.
Use localstorage to store common
fragments.
Tell the server about known fragments so
that only identifiers from the previous
page are sent, in place of the actual
content.
14. <!doctype html>
<html>
<head>
<title>Transparent client-side fragment cache demo</title>
</head>
<body>
<!--fragment navbar-290d996311209f1897516b2caa2cc611-->
<nav>
Navigation bar
</nav>
<!--/fragment-->
<!--fragment ads-bd779001f9cad4bfb74e563eb6bbf5c5-->
<div id="ads">
Ads
</div>
<!--/fragment-->
<section id="hey">
I ain't no <a href="/">fragment</a>!
</section>
<script src="disco.js"></script>
</body>
</html>
15. <section id="hey">
I ain't no <a href="/">fragment</a>!
</section>
gets dynamically rewritten as:
<section id="hey">
I ain't no <a href="/?
_fragments=navbar-290d996311209f1897516b2caa2cc611+ads-
bd779001f9cad4bfb74e563eb6bbf5c5">fragment</a>!
</section>
16. <!doctype html>
<html>
<head>
<title>Transparent client-side fragment cache demo</title>
</head>
<body>
<!--cached navbar-290d996311209f1897516b2caa2cc611-->
<!--cached ads-bd779001f9cad4bfb74e563eb6bbf5c5-->
<section id="hey">
I ain't no <a href="/">fragment</a>!
</section>
<script src="disco.js"></script>
</body>
</html>