This examples shows a sample implementation of predictive prefetching with TensorFlow.js and Angular. You can find more information about how the entire end-to-end solution works in the blog post "Speed-up your sites with web-page prefetching using Machine Learning."
The demo is inspired by the Google Merchandise Store, but does not share any data nor implementation details with it.
To try the example yourself, go through the following steps:
- Install the dependencies of the client and the server:
cd client && yarn
cd ../server && yarn
- Start the server. In a terminal window run:
cd server && yarn start
- Start the client. In a terminal window run:
cd client && yarn build
cd dist/merch-store
npx serve -s .
When you open the browser (by default http://localhost:5000) and navigate through the application in Chrome DevTools you should see logs similar to:
You can track the activity in the "Network" panel to find the requests the service worker makes based on the predictions:
MIT