简体   繁体   中英

Content of a web page changing during reading

In java, when we establish a connection to a given URL and then open a stream to read from it, what happens when the content of the website changes halfway through reading?

For instance, our cursor was pointing to at line 1000, which was supposed contain a chapter title, but now the page has something completely different at line 1000, or perhaps the content is no longer as big as 1000 lines?

What happens if a given website updates its content every 1-2 secs, with eg stock changes, which might include only stocks that ticked in the last 1 sec (content grows and shrinks)?

The behaviour of what actually happens depends entirely on the web server itself and is outside the control of the client.

Most web servers will send and entire, complete document all at once, as if it were a "snapshot" in time of some particular document state.

IMHO the http server will send the content available when the client asks for a resource.

Example:

  • The clients asks for the index.html page GET /index.html
  • The server sends the entire page in one session.
  • The client parses the page and finds that it points to a css file, so it asks for the file.. etc..

So you can't get the first part of a HTML page then a second part of another version, as the server serves the entire page at once.

Dynamic pages have usually static layout and the data is updated using ajax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM