📱 Phone Cache Lab

Keep a few pictures close by. Predict hits and misses, choose what gets replaced, and discover why using a picture changes its place.

A simplified learning model, not a real phone benchmark. Each picture uses one equal-sized slot. A miss fetches one picture from an imaginary source; a hit needs no fetch. All pictures stay unchanged. Real apps have different cache rules, image sizes and expiry behaviour. We do not measure speed, battery use or mobile data.

1. Set up your experiment

Request order

2. Watch the cache

Read from least recently used → most recently used. On a hit, the picture moves to the most-recent end. On a miss with no free slot, the least-recent picture is evicted (removed).

    Cache empty.

    Request log

    3. Cache detective missions

    1. Repeat visits, 2 slots: predict each result before clicking. When A is requested for the second time, does it stay least recent? Write down the final misses.
    2. Change to 3 slots. Run the same requests and compare misses. Change only the cache size so the experiment stays fair.
    3. Gallery scan, 2 slots: every picture appears twice. Does that guarantee a hit? Look at what was evicted before the second visit.
    4. Favourite picture, 2 slots: follow A. Why does A survive while other pictures are replaced?

    The maths

    Every request is exactly one hit or one miss. Hit rate = hits ÷ requests × 100%; the display rounds to a whole percent. Before the first request, the rate is undefined, shown as a dash. Without a cache this toy model fetches every picture. Fetches avoided = hits; it is not a claim about bytes or seconds saved.

    LRU is not FIFO

    LRU = least recently used. Accessing a cached picture updates its position. A FIFO queue removes the item that arrived first, regardless of later accesses. Test A, B, A, C with two slots: which picture does each rule remove? Caching also differs from deleting your own photos: this model replaces temporary copies only.

    4. Check your reasoning

    Keep exploring

    Phone Storage Mission · Download Time Detective · All courses

    No account, saved scores, browser storage or input uploads. Reloading resets the experiment.