In that case, it should download the page from the beginning because the TCP connection was closed, right? If it's not the case, how does Tor know when the site has finished loading?
2 Answers
Tor can change circuit while accessing a web page but it will not cause problems except in special cases. The explanation is below.
Current browsers and web servers - few TCP connections needed
Usual web pages contain a lot of resources (text, images, videos, styles, scripts...) which could all be downloaded in a single TCP connection when all the resources are on the same server and HTTP keep-alive is being used (default since HTTP version 1.1). Even after the complete page is downloaded the browser and the server keep the TCP connection open for a short time (usually several seconds). During this time even a new page or a script request could be served in the same connection.
In other cases more than one connection will be used. ...but there is also another catch. Browsers usually open multiple TCP connections in parallel to achieve higher speed and responsiveness. So even if the conditions above are met, different resources on the same page can be downloaded over different TCP connections.
How does Tor change circuits?
Tor always serves a whole TCP connection over a single circuit otherwise a changed exit relay (new source IP address seen from the Internet) in a new circuit would cause the existing TCP connection to break.
By default Tor client stops using a circuit 10 minutes after its first use but existing connections will still be routed through their old circuits. It is explained here: How can I prevent my different activities carried out over Tor being linked?
What are the consequences?
Normally Tor will serve a single web page over a single circuit even in case of parallel connections, web page resources on different servers or HTTP keep-alive not being used. From time to time the 10 minutes expiration can happen during a web page loading but the existing connections will be finished over the old circuit and the new ones over the new circuit.
Very often the 10 minutes circuit change will happen when a web page loading is finished. A subsequent action loading a new page will be served over a new circuit.
If the web server does not watch for IP address changes during the user's session (usually identified by cookies) or if the session information is not connected with the client IP address (e.g. looked up by the IP on the server, server load balancing based on client's IP address) then there would not be a problem.
The TCP connection closes when the webpage finishes loading. In HTTP/1.1 you can use the same TCP connection to download all the files on the webpage (images, CSS, scripts), but in any case, the TCP connection is closed when the webpage ends. Further access to same site (like clicking on a link) may happen over a different circuit.