Architecture

Caching: what to cache and how to refresh it

Caching can make an application far faster, or serve stale data at the worst moment. Where to cache, what to cache and how to keep it fresh.

GloryTekSystems team22 Apr 2026 2 min read

A developer writing code on a laptop in front of large monitors

Caching stores the result of expensive work so it can be reused. It is often the cheapest way to make an application faster and to reduce database load. It is also where subtle bugs live: the hard part is not storing data but knowing when it has gone out of date.

Layers of caching

  • Browser and CDN caching for static files and public pages
  • Application caches, such as Redis, for frequently read data
  • Materialised views and summary tables for expensive reports
  • In-process caches for small, rarely changing reference data

Choosing what to cache

Good candidates are read often, change rarely and are expensive to compute: product catalogues, configuration, hourly exchange rates, dashboards. Poor candidates are personalised, fast-changing or security-sensitive data, such as account balances or permissions.

Keeping data fresh

Give every cached item an expiry time, even if you also clear it on change. Prefer updating or clearing the cache when the source data changes, and include the tenant and user in cache keys wherever data differs between them. Protect against a stampede when a popular item expires by letting one request refresh it while others wait or receive the previous value.

Written by the GloryTekSystems team

Our engineers and consultants write about what they see in real projects. Have a question about your own systems?

Ask us
GloryTek assistantQuick answers · automated

Hi, I’m the GloryTek assistant. Ask me about our services, pricing, timelines or industries.

Popular pages

↑↓ to move to open Esc to close