Proxy Pattern
Updated 2026-07-30
Summary
The proxy pattern is a design pattern in programming. A proxy, in this context, refers to a class that can serve as an interface to something else. A proxy can act as an interface to anything: network connections, large objects in memory, files, or other resources that are expensive or impossible to duplicate.
Definition
Provide a surrogate or placeholder for another object to control access to it. Scaffold use: Control access and enhance functionality. A secretary is a proxy for the CEO; a CDN is a proxy for the server. As a scaffold, it teaches us to establish a 'buffer' between core resources and external requests: performing permission control, cache acceleration, or logging to protect the core from direct impact.
Introduction
How to use
Control access and enhance functionality. A secretary is a proxy for the CEO; a CDN is a proxy for the server. As a scaffold, it teaches us to establish a 'buffer' between core resources and external requests: performing permission control, cache acceleration, or logging to protect the core from direct impact.
Mechanism
Insert a proxy object between the client and the target object, with the proxy intercepting and controlling access to the real object. The proxy can add enhanced logic such as permission checks, caching, logging, or lazy loading before and after forwarding requests; the real object remains transparent to the client, which believes it is interacting with the real object, but all calls are actually routed through the proxy.
Practice
In progress 0/4Practice this model in one real situation:
Cases
- A secretary acts as a proxy for the CEO to filter visitors and schedule; a CDN acts as a proxy for the origin server to cache static resources for faster access; front-end uses virtual proxy to delay creation of large objects (e.g., image lazy loading).
Common pitfalls
- Treating the proxy as a pure transparent forwarder, forgetting its 'control and enhancement' purpose, leading to the proxy accumulating unrelated logic and becoming a god object; or overusing proxies, increasing call layers and latency.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8Fverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS