An internal machine will connect to the proxy machine on your network, not to the external machine. The proxy will go and fetch whatever data the internal machine asks for, and pass it on to the internal machine. Usually, the proxy maintains its own cache, so if another machine asks for the same information, the proxy will retrieve the information from its cache and save itself the trip to the network.
Advantages can be faster if the cache is used and large enough.
The cache may not be aware that a page is generated on the fly and it may present an outdated version. It will just replace the internals machine IP address with its own IP address and pass it on to the external machine. As the response returns, the gateway machine will pass the response on to the internal machine. The internal machine is usually not aware of the presence of the router. You just set your 'gateway' address to the internal IP address of the router.