How it works...
Our page caching strategy relies on us having a reliable key with which we can look up pages before bothering to set up an external HTTP request. To do this for our first page, we changed our optional pageToken parameter to be automatically defined as the first page if there is no value provided. This means that, when the first page result is loaded, it will be automatically added to our cache under this key value. Then, the next time we load this component without providing a key, it will default to the first page and find and reload the cached value instead of making an HTTP request. We can reuse this solution for the same requests that provide defined pageToken parameters, so we get great flexibility from this caching solution. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access