Web Proxy / Caching Fundamentals Series

🎧 [Listen] The Web Proxy/Caching Fundamentals Series, Fully Recapped

This article is an audio-learning recap for anyone who’s already read all seventeen articles in the Web Proxy/Caching Fundamentals series. Use your browser’s or phone’s text-to-speech feature and let it play in the background during a commute or while doing chores. There are no diagrams, tables, or code here — just spoken-style prose, stitching the whole series back together into a single, continuous thread.

The series started with when to use a proxy versus a firewall. Both control traffic, but we covered the difference between explicit proxying, where the client specifies a proxy server, and transparent proxying, where traffic gets relayed without the client ever knowing, along with how cloud proxies (SWG) and zero trust relate to this.

Next came the difference between forward proxies and reverse proxies. Every proxy this series has built so far has been a forward proxy, acting on behalf of the client — but an entirely opposite kind, a reverse proxy acting on behalf of the server, exists too. The axis separating the two is the direction of representation itself: which side’s identity the proxy hides. And don’t forget: HAProxy, nginx, and CDNs are prime examples of a reverse proxy, with load balancing and content delivery as just applied uses of that role.

Next came the Via header. Separate from the non-standard X-Forwarded-For, which records the client’s real IP address, the HTTP spec itself defines a standard mechanism called the Via header, recording the history of proxies a request or response passed through. Passing through multiple proxies builds up a comma-separated history, and a proxy can detect an unintended forwarding loop by checking whether its own identifier already appears. And don’t forget: “widely used” and “standard, as defined by the HTTP spec itself” are separate axes.

Next came the rise of HTTPS and the end of proxy caching. A proxy server used to reduce traffic volume by caching website content, but once HTTPS became the norm, the proxy lost the ability to decrypt the traffic’s content, and caching’s main role shifted to the browser’s own cache and the CDN — a historical shift we covered in detail.

Then came putting everything from the lecture into practice, hands-on, actually building it with Squid. You implemented URL-level access control through a mechanism called an ACL, and read through the access log to confirm exactly which requests got allowed and which got denied.

After that came the CONNECT method, a mechanism built into HTTP itself. When a client accesses an HTTPS site, it sends the proxy a CONNECT request: “relay a TCP connection to this hostname and port.” Once the tunnel is established, the proxy can’t see the encrypted traffic’s contents at all, and knows only the destination hostname and port number — which is exactly why the URL-path-level control possible for HTTP sites only ever works at the hostname level, by default, for HTTPS sites. And don’t forget: this blind CONNECT tunnel and SSL inspection, which deliberately decrypts the traffic, are two entirely different operating modes — SSL inspection separately requires a certificate-trust configuration on the client side.

Next came WebSocket through a reverse proxy. The Upgrade header is classified, by the HTTP spec itself, as a “hop-by-hop header” a proxy carries no obligation to forward, and a reverse proxy like Nginx never forwards it without explicit configuration. Explicit settings via proxy_http_version 1.1 and proxy_set_header are required, and don’t forget another pitfall: a reverse proxy’s default idle timeout can forcibly sever a long-lived connection.

From here, the series moved into more advanced territory. First, PAC files and WPAD. Manually distributing proxy settings to hundreds of machines across a company isn’t realistic. We covered the two-stage mechanism: a PAC file, a single function written in JavaScript, expressing the logic for which proxy to use based on URL or hostname, and WPAD, automatically discovering that PAC file’s own location using DHCP or DNS.

Next came proxy authentication. The three methods, Basic, NTLM, and Kerberos, could be understood as a staged design decision about how much of the password, a piece of sensitive information, you’re willing to expose on the network. Basic is effectively plaintext, NTLM exchanges only a value derived from the password via a challenge-response scheme, and Kerberos uses a ticket, never letting any information about the password travel over the network at all. We also covered status code 407, separate from 401, signaling that the proxy itself is demanding authentication.

Then came Cache-Control and the Vary header. We covered how max-age represents the cache’s valid duration, no-cache instructs “store it, but re-validate before use,” and no-store instructs “never store it at all” — three separate instructions. And we covered how the Vary header makes requests to the same URL get managed as separate caches, whenever the value of a specified request header differs.

Next came cache stampede. The instant a popular cache entry’s TTL lapses, every one of the concurrent requests for that key misses the cache all at once and rushes the origin server — a cache simply expiring, completely normal behavior, unintentionally turning into a self-inflicted DDoS attack against the origin. Request coalescing (single-flight) forwards only the first request, stale-while-revalidate returns the old data instantly while revalidating behind the scenes, and TTL jitter prevents a mass simultaneous expiration — and don’t forget, combining all three together is what’s recommended in real-world practice.

Next came web cache deception and web cache poisoning. Cache deception abuses a mismatch between how the cache layer and the origin server interpret the same URL, tricking the cache into wrongly treating a page with personal data as a static asset. Cache poisoning abuses an input like X-Forwarded-Host that actually affects the response yet never got included in the cache key, letting one malicious request keep poisoning every subsequent visitor’s response afterward. And don’t forget: these are two separate attacks, with different underlying mechanisms.

The final article put building Squid as a caching proxy into practice, hands-on, actually confirming everything from the lecture. You confirmed a second access to the same URL showing HIT via the X-Cache header, answered instantly without ever querying the origin server at all. You confirmed it returning to MISS once the max-age expiration passed. And you confirmed, with your own hands, that accessing with different Accept-Language headers got correctly separated into distinct caches thanks to the Vary specification — and that removing that Vary specification let a response that should have been separate get incorrectly served from the same cache instead.

From here, the series moved into two more advanced hands-on labs. First, building a transparent proxy with iptables and Squid. Where an explicit proxy required configuring a proxy address on the client side, iptables’s REDIRECT target rewrote an HTTP connection’s destination to the local Squid instance, without the client ever noticing, and Squid’s intercept mode correctly relayed that traffic with its disguised destination. This convenience comes at a cost: since the client validates the destination’s certificate on HTTPS traffic, silently rewriting the destination fails certificate validation, so a transparent proxy only ever works, in principle, for unencrypted traffic.

The final article was a hands-on reproducing Squid’s open-proxy danger and defending with ACL-based access restriction. Building a proxy with zero access restriction configured turns it into an “open proxy,” accepting a relay request from anyone, regardless of source, carrying a real danger of getting abused as a stepping stone, letting a third party hide their identity while attacking another server. You confirmed that Squid’s acl configuration prevents this danger, by explicitly defining the allowed source network and explicitly denying everything else. The lesson: access control is premised on closing with an explicit final deny rule, not just listing allow rules.

Next came ICAP, a mechanism where instead of building virus-scanning into the proxy itself, the job gets handed off to a dedicated server. The virus scanning and DLP checks a corporate proxy provides aren’t actually performed by proxy software like Squid itself — they’re handed off to a dedicated ICAP server through ICAP, a thin relay protocol. Don’t forget: REQMOD inspects a request (such as an upload) and RESPMOD inspects a response (such as a download), at entirely separate times, and a 204 No Content response is an efficiency mechanism that avoids re-sending content that has no problem.

The final article wasn’t about learning a new technique, like earlier ones. It was a capstone project: given the setting of a fictional multi-site retailer, “KoiKoi Retail,” building an internet access infrastructure, you designed, with your own hands, a single integrated internet access infrastructure combining everything you’d learned separately — auto-configuration via PAC files/WPAD, proxy authentication, cache control via Cache-Control/Vary, a transparent proxy, and open-proxy hardening. The ability to follow a fixed procedure and the ability to design on your own from requirements are entirely different skills, and even having finished every individual hands-on, you’re not immediately effective in real-world work without the experience of combining them into one coherent infrastructure.

Looking back across all seventeen articles, one consistent pattern emerges. The difference in layer between explicit and transparent proxying, the difference between the Via header and X-Forwarded-For — two headers entirely different in what they record and in their standardization history, the Upgrade header’s own identity as a hop-by-hop header, cache stampede’s structure where correct behavior becomes an incident once it happens collectively, cache deception and cache poisoning as two attacks abusing an interpretation mismatch between the cache and the origin, ICAP’s structure separating a proxy’s relaying role from content inspection, the direction of representation itself separating forward and reverse proxies, the entirely different operating modes of a CONNECT tunnel versus SSL inspection, the difference between a PAC file’s decision logic and WPAD’s discovery mechanism, the staged difference in how much sensitive information gets exposed across Basic, NTLM, and Kerberos, the difference between Cache-Control’s duration and Vary’s distinguishing condition, a transparent proxy’s real identity as a destination rewrite via iptables, the open proxy’s risk structure common across relay-type services in general, and the entire internet access infrastructure you integrated in the capstone project — every one of them shared the same shape: behind what looks like one single, simple mechanism, several independent decision axes are actually combined together. Looking at a proxy’s or a cache’s behavior in front of you, and digging one layer deeper to ask what the real decision axis underneath actually is. That’s the perspective a top-1% engineer carries away from this series. And that’s the recap of the Web Proxy/Caching Fundamentals series, complete.

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).