From the course: Improving Performance with IndexedDB and Caching

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Challenge: Keep your data up to date

Challenge: Keep your data up to date - JavaScript Tutorial

From the course: Improving Performance with IndexedDB and Caching

Start my 1-month free trial

Challenge: Keep your data up to date

(upbeat music) - [Instructor] Now that we have our data stored in IndexedDB and being retrieved, we need to ensure we keep it up to date. For this challenge, you're going to create a new object store. Inside this store, we're going to store the timestamp that each of the other stores was last updated. This way, we can set an expiry time for our data, after which we can check for an update. Depending on the data that you're working with and how often it is likely to update, the amount of time you want to allow before your data expires will change. For this challenge, let's use 30 minutes. You may want to reduce that time when testing. So what we want to do is first of all, grab the data as normal and store it. At the same time, we want to store the timestamp of when we fetched the data. On the next request, we want to grab the current timestamp and compare it to the one we stored the first time around. If the first…

Contents