Now that files are in the cache, how do you get them back out so that you don't have to go to the network to get them every time? In this video, get a code walk-through of how to implement this.
- Now our images and CSS, … have been stored in the cache. … We can retrieve them in the next request. … We're going to use a local first caching strategy here, … as these files are unlikely to change very often. … So we can safely store them in the cache, … without having to worry about … showing the user and outdated application. … We will look at how to store … different kinds of assets in the next video. … First of all, we need to listen for the fetch event. … We can do this by adding a new event listener for fetch, … giving that a call back with the events property. … This event fires when any http request is made. … So we need to check that it is a request … for one of the files we've cached. … So I'm going to write an if statement … and check that the request exists within … the arrays of files that we have cached. … To do that I'm going to create a new array, … and I'm just going to spread … the different kinds of files … into that, right? … Then I can check if that ray … includes the event request URL, …
Skill Level Advanced
Web Programming Foundationswith Morten Rand-Hendriksen58m 44s Beginner
1. Front-End Performance Tools
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.