Chapter 7. Optimizing After First Load

Optimizing performance for future visits is very important to increase conversions and improve the user’s perception of our services and our companies. We can take advantage of previous visits to increase speed of later experiences with the same website. Bad connections and being offline are usual situations on the mobile web; therefore, taking advantage of techniques like caching and prefetching content can enhance the user experience.

In this chapter, we will talk about browser and custom caches, prefetching, and offline experiences to optimize near-future visits (such as what the user is doing in the following few seconds) as well as far-future visits (such as next month’s).

The Cache: Your New Friend

I remember the days when every developer was looking for a way to remove the browser’s cache at all costs. Googling “no cache in php” was pretty common in the late ’90s and early 2000s. We weren’t thinking about performance at the time, and the impact of disabling cache abilities was really costly.

Now you are here, reading this book, so you know that performance is a very important feature—and you are now ready to make the cache your new best friend.

The first thing is to understand how browser caching works. Every browser has a database of HTTP resources that have been downloaded before, including the data itself and metadata such as the fetch timestamp and expiration timestamp (provided by the server).


When a browser is loading a ...

Get High Performance Mobile Web now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.