Proxy Design Pattern Explained
Proxy provides a substitute or placeholder object that controls access to another object, adding behavior like lazy loading, caching, or access control.
Published November 13, 2026
The Proxy pattern places a stand-in object in front of another to control access to it: lazy loading, caching, permission checks or remote calls, while exposing the same interface.
The concept
The client uses the proxy exactly like the real object. The proxy decides when and whether to forward the call.
Types: virtual (lazy), protection (access control), remote (network stub) and caching proxies.
Gatekeeper
Practical examples
JavaScript Proxy
const user = new Proxy({ name: 'Ada' }, {
get: (t, k) => (k in t ? t[k] : (console.warn('missing', k), undefined)),
set: (t, k, v) => { if (k === 'age' && v < 0) throw Error('bad age'); t[k] = v; return true }
})Caching proxy
const cached = (api) => { const m = new Map(); return { get: (id) => m.get(id) ?? (m.set(id, api.get(id)), m.get(id)) } }Lazy loading
class LazyImage { get src() { return this._s ??= loadHugeImage() } }Common mistakes
- Proxies that change the interface.
- Hiding latency of remote proxies.
- Forgetting to invalidate cache proxies.
Key takeaways
- Same interface, controlled access.
- Lazy, cache, protect, remote.
- Keep it transparent.
FAQ
Proxy vs Decorator?
Proxy controls access to an object; Decorator adds behaviour.
Reverse proxy?
A network-level proxy in front of servers, same idea at infrastructure scale.