Web and Mobile Development - Cache

Activity Goals

The goals of this activity are:
  1. To explain the benefit and risk of using a cache
  2. To use the HEAD verb to check the modified date on an item for refreshing

The Activity

Directions

Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to take notes for the group, and appoint another member to discuss your findings with the class. After class, think about the questions in the reflective prompt and respond to those individually. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.

Model 1: Checking Modification Date Using the HEAD verb

HTTP HEAD Example

Questions

  1. How is this less expensive than making a full GET request, when we still need to do that anyway if the modification date from the HEAD response is newer than the version we have?
  2. In addition to the response data (such as the web page), what other information would you need to store for the cache to be effective?
  3. What kind of data structure would you use to save values into the cache?
  4. How often should you refresh the cache?

Model 2: Internal Caches with node-cache

Review this tutorial that uses node-cache to return data from a cache lookup, calling a function to insert into the cache only if the data is out of date or nonexistent.

Questions

  1. What data structure do you think underlies node-cache?

Submission

Submit your answers to the questions using the Collaborative Spaces section of OneNote. You can add a page with your name and your group members' names, and today's date, as the title. Under the appropriate section (i.e., "Class Notes", "Collaborative Spaces", "Reflective Prompts") that you can select on the left side of the screen, you can click "Add Page" on the right side. You can answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section.