- Use
npm run start
in the project directory to start the app. - Navigate a browser window to http://localhost:8000/goat0.
- Check logs in terminal where server is running.
- Refresh the page before the key gets deleted to verify cached key being fetched by watching logs.
- Try with other two goats, replacing
/goat0
in URL with/goat1
or/goat2
.
- When a path is first loaded via the URL, it's corresponding key, e.g.,
goat0
, is saved in memory with a value of its path to the associated art file. - After ten seconds, the key/value pair in memory are deleted.
- If you refresh the page before it is deleted, you'll notice the logs with say
"... fetching cached key: ..."
instead of the initial"... fetching non-cached key ..."
you saw after first page load. - If you refresh the page after it is deleted, you'll see the same behavior as initial page load:
"... fetching non-cached key ..."
Special thanks to Admiral Potato from The Unaffiliated Developer Standup Meetup Group for helping me create this example app.