Use AI as a Tutor for Technical Concepts
An original worked conversation that teaches caching through examples, checks misunderstandings, and turns the lesson into a hands-on experiment.
An original worked conversation that teaches caching through examples, checks misunderstandings, and turns the lesson into a hands-on experiment.
Be my technical tutor and explain caching to someone who can use spreadsheets but has never built a web application. Begin with a familiar analogy, connect it to an application, and explain where the analogy stops being accurate. Avoid introducing several unexplained technical terms at once.
Use a fictional weather page as the running example. I want to understand why it might show yesterday's temperature even when the weather service has newer data. End with one question that checks my understanding rather than asking whether the explanation was clear.
A cache is a saved copy kept so a system can reuse an earlier result quickly. Think of writing a frequently used phone number on a sticky note instead of opening a directory every time. The note saves effort, but if the number changes, the note does not automatically change with it. A weather page can similarly reuse a previously fetched temperature.
The page may save the weather service's response for a chosen period. During that period it can display the saved value without requesting another response, depending on how the application is designed. This is one possible cause of stale weather data; a page could also have a different bug, so an old temperature alone does not prove the cache is responsible.
The sticky-note analogy has limits because software can attach timestamps, distinguish different requests, and replace copies automatically. The key tradeoff is how much freshness the application needs versus the effort and delay of retrieving another value. Check your understanding: if a saved forecast is reused for an hour and the source changes after ten minutes, under what conditions could the page still show the earlier forecast?
My answer is: the page must always show the newest forecast because the weather service updates it. Identify the mistaken assumption in my answer and correct it without introducing advanced browser-cache rules.
Then walk through a simple example with a ten-minute cache lifetime: the page retrieves 24 degrees at 09:00, the service changes to 26 degrees at 09:03, and visitors open the page at 09:05 and 09:11. State the exact simplifying assumptions needed to predict what they see.
The mistaken assumption is that changing the original data automatically changes every saved copy. A saved response only becomes fresh when the system replaces it or decides to stop using it. In this simplified model, the page does not receive update notifications and does not check the source on every visit.
Assume one shared cache entry, a ten-minute lifetime measured from retrieval, no background refresh, no other caching layers, and a successful source request when the saved entry expires. The 09:05 visitor receives 24 degrees because the 09:00 copy is still valid under this rule. The 09:11 visitor triggers a new request and receives 26 degrees, assuming the source still reports that value.
Expiry does not necessarily mean an automatic request happens at exactly 09:10. In this example it means the next visit cannot reuse the expired copy. A useful follow-up prompt is: Change one assumption in this timeline, predict how the result changes, and explain which event refreshes the stored value. This encourages understanding the mechanism instead of memorizing the two temperatures.
Give me a hands-on caching exercise I can complete in a spreadsheet without coding. I want to predict the displayed temperature at several visit times and compare that prediction with the rule we defined. Include a variation where the source request fails.
Finish with a teach-back exercise and a rubric for spotting gaps in my explanation. Keep the activity self-contained, and make clear which behavior is our chosen policy rather than a universal rule followed by all software.
Create columns for visit time, current source temperature, last successful fetch time, cached temperature, cache age, and displayed result. Use visits at 09:00, 09:05, 09:11, and 09:14. Set the source to 24 degrees initially and 26 degrees from 09:03 onward. Apply the rule: if there is no copy or its age is at least ten minutes, fetch and replace it; otherwise reuse it.
Under successful requests, the displayed values are 24, 24, 26, and 26 degrees. Now make the 09:11 request fail and choose a visible policy: display the previous value with a stale-data label and retain its old fetch timestamp. That means later visits still attempt a refresh. An alternative application could show an error instead; serving stale data is our explicit exercise policy rather than an inevitable feature of caching.
Teach the idea back in four sentences: what is stored, how long it is reused, what triggers replacement, and what happens when replacement fails. Check your explanation for the false claims that source changes instantly update copies or that expiry always triggers an immediate request. If you can predict a new timeline and state its assumptions, you have stronger evidence of understanding than simply recognizing the word cache.
Comments 0
Share how you would use this prompt or suggest a useful improvement.