.. (לתיקייה המכילה) | ||
Should we implement the ICache interface? | |
No, you can ignore it (it's irrelevant for this assignment). |
When testing our proxy server with a browser, we receive the error "Client closed connection". Can you help us to understand the reason for this error, and tell us how we can avoid it? | |
In order to obtain better performance, browsers send simultaneously multiple requests to a server. I.e., when several resources are required for a certain page, for example CSS files, JS scripts and images, it would be beneficial to send multiple requests simultaneously, rather than to have a sequence of requests. Proper servers use threads to handle client requests, and for that reason the above scenario usually works well. In our proxy server, only one request is being handled at any given time, while other requests wait to be accepted by the server. When the waiting time is longer than some threshold, the browser concludes that there is no point on waiting any longer and decides to close connections that have exceeded this time period. By the time the server accepts one of these requests, it finds out that the connection has already been closed, and therefore the exception "Client closed connection" is being thrown. In Firefox we can limit the number of concurrent connections per server by going to about:config, and changing the value of the property network.http.max-persistent-connections-per-server to 1. Credits for this answer go to Uri Alon and Amir David Nissan Cohen. Kudos! Note that this error is caused due to certain assumptions the browser makes about the server model. That is to say, besides making sure that the server doesn't crash in the above scenario, you don't need to dwell on it (as far as this assignment is concerned). |