What is Cache?
A saved copy of a page or data, reused to be fast. Until refreshed, it can show old information.
Where Cache goes wrong in real apps
Each of these is a short scenario built from a real failure in an app made with AI. Read the answer here, or walk through it yourself in about four minutes.
Launch day · 4 minutes · Pro
The old price
You raised your price an hour ago. Your admin page shows the new price. Customers are still checking out at the old one.
Read the fixWhy do customers still see my old price?
The page is cached: a saved copy is served to visitors until it expires or is refreshed. Your admin page reads the database, so it looks right. Refresh the cache whenever prices change, and always calculate the amount you charge on the server, never from the price the page sends.
Launch day · 4 minutes · Pro
Same answer, 50,000 times
Your product pages show prices in the visitor's currency. Pages feel slow, and the currency API bill grows with every visitor.
Read the fixHow can caching make my app faster and cheaper?
If many visitors need the same slowly changing answer, such as exchange rates, fetch it once on the server and reuse it for a set time instead of calling a paid API on every page view. Pages skip the wait and you pay for one call instead of thousands. Never put personal data in a shared cache.
Bills that explode · 4 minutes · Pro
A quiet week, a loud bill
Almost nobody visited your site this week. Your hosting bill is forty times higher than usual.
Read the fixWhy is my hosting bill high with few visitors?
On usage-based hosting you pay for every request, compute second and gigabyte, whether a person or a bot sent it. AI crawlers can send tens of thousands of requests that each trigger paid work. Block unwanted crawlers at your host, cache expensive pages and images, and set a hard spend limit.
Bills that explode · 5 minutes · Pro
The address box that cost $1,900
Your checkout suggests addresses as people type, using a maps API. Orders are steady, but this month's maps bill is $1,900.
Read the fixHow do I reduce my Google Maps API bill?
Count what triggers each call. Address autocomplete often sends a billable request on every keystroke. Wait for a short pause and a few characters, use session tokens so searches can be billed together when a place is chosen, restrict your key to your site and the APIs you use, set daily quotas, and cache only what the provider's terms allow.
AI inside your app · 4 minutes · Pro
The chat that got expensive
Your AI tutor costs about a cent per message for new users. One student's 400-message chat now costs 30 cents per message, and replies take ages.
Read the fixWhy do long AI chats cost so much?
Chat models don't remember between requests, so apps resend the conversation each time, and you pay for every token sent. Message 400 carries the 399 before it, so cost and wait time grow with every turn. Send recent messages in full with a summary of older ones, use prompt caching, cap tokens per request and track spend per user.
Bills that explode · 5 minutes · Pro
The 4 MB thumbnail
Your marketplace shows 24 small product photos per page. On phones it takes ages to load, and your storage bill warns you are over your data transfer limit.
Read the fixWhy are my uploaded images making my app slow?
Your app is probably storing and serving the full-size photos users upload, often 4 MB or more, even where they are shown as small thumbnails. Browsers download the whole file before shrinking it. Create smaller copies at upload or with an image service, serve WebP or AVIF, and give each screen the size it needs.
Related terms
- Request
- A message your browser (or any program) sends to a server asking for something: 'give me invoice 105' or 'save this profile'.
- API
- The part of an app that other programs talk to. Your app's pages ask its API for data, like a waiter taking orders to a kitchen.
- Server
- A computer that runs your app's code out of sight. Users can't change what happens there, which is why checks belong there.
- Browser
- Chrome, Safari and friends. Everything that runs here is visible to, and changeable by, the person using it.
- Database
- Where your app keeps its data, organised in tables, like a set of spreadsheets.
- Token
- A temporary pass that proves who you are. Access tokens expire quickly; a refresh token quietly gets a new one.