> For the complete documentation index, see [llms.txt](https://petercheng7788.gitbook.io/developer-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://petercheng7788.gitbook.io/developer-note/backend/cache/proxy.md).

# Proxy

## Forward Proxy vs Reverse Proxy

### Forward Proxy

![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2Fymh7VzVrspRRxqOXlmPa%2Fimage.png?alt=media\&token=5a6c4293-0286-44c4-89aa-b3f93bfa9373)

* It is a server sitting between clients and internet
* It can be used to hide the ip address of client side, bypass the restriction rule from firewall and block access to certain content before accessing to internet

### Reverse Proxy

### ![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2FdnktseA8SjzYXvtho0SV%2Fimage.png?alt=media\&token=8fcda18d-676b-407e-b077-acfc53fba5b2)&#x20;

* It is a server sit between internet and web server
* It can help to protect the location of server
* Caching for the content
* Load balancing for the web servers
* Minimizing the needs of SSL encryption, as client only need to send https request to the proxy server
* Examples: Load balancer, CDN, API gateway, etc

## CDN (Content Delivery Network)

![](https://1374779285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFW3x2aqEO8GF2kr3VU%2Fuploads%2FzNsc39HW3YQpKHMCenzA%2Fimage.png?alt=media\&token=68987c02-785d-40d7-bbcb-6a389527e5fa)

* CDN deploys edge servers around the world, the server location is called point of presence (PoP)
* When user make a request to CDN, it will direct the request to the closest edge server
* When user make the same request content request to CDN, it will return cached response from edge server instead of making request to origin web server in order to reduce latency
* It also prevent from DDOS attack as CDN contain lots of edge servers and hide the location of web server

## References

{% embed url="<https://www.youtube.com/watch?v=RI9np1LWzqw>" %}

{% embed url="<https://www.youtube.com/watch?v=4NB0NDtOwIQ>" %}
