Asked about The cost maths, and caching whole responses

Your cached prefix has a five-minute lifetime. How often do requests have to arrive before caching pays?

An answer that works

Break-even is a hit rate, and it comes from the multipliers: a write costs about 25% more than plain input and a read a tenth of it, so a hit has to repay the extra quarter, which is 0.25 over 1.15, or roughly 22%. Treating arrivals as Poisson, that hit rate is reached when the mean gap is about four times the lifetime, so with five minutes you need a request roughly every twenty minutes. Rarer than that and caching costs more than not caching.

Then they push further

It is rarer than that and you cannot change the traffic. What now?

Make the requests arrive together rather than spread out, by batching the work, so one write serves several reads. Or buy a longer lifetime if the provider sells one and compare its price against the write premium you are paying repeatedly. Or accept that this prefix should not be cached and spend the effort on a prefix that is.

What gets marked up

Strong answers reason in hit rate against the lifetime rather than in total request count, and know that a cache can be a net loss rather than merely ineffective.

Reading an answer is not being able to give one. The section that teaches this is The cost maths, and caching whole responses, 4 hours of Prompt caching.

Learn this properly