Reputation: 9397
Do Apache connections close immediately after a server serves the web page?
Also, if you are hosting all your static assets (JS, CSS, images, etc) on the same server as your site, how does that affect Apache connections?
Upvotes: 0
Views: 6108
Reputation: 7729
Whether or not Apache closes a connection immediately after serving a page depends on
Connection: Keep-Alive
header.KeepAlive
and KeepAliveTimeout
parameters. See http://httpd.apache.org/docs/2.2/mod/core.html#keepaliveAll types of content use the same 'pool' of connections.
Good question: because all content uses the same KeepAlive settings, you may wish to setup different servers to handle different types of content.
--
For your next question:
It's the total number of requests a client can make on one "kept alive connection". If you have lots of server resources you should keep it high. Or you can lower it to send clients away and give someone else a turn if you have low server resources or many clients. Don't forget that after the last request from the client the server will still wait "KeepAliveTimeout" seconds before closing the connection and making that worker available for another client.
It's the number of client requests (and individual requests over a kept-alive connection count for 1 each still) before the child server process will die. Different MPMs (ie Apache backends developed specifically for individual platforms that implement these child server processes) behave differently:
Upvotes: 3
Reputation: 71384
The answer to your question is maybe. The connection might stay open depending on your KeepAlive
settings. If you turn KeepAlive
off altogether, then the connection will close after the request is satisfied. If you have KeepAlive
on (which is more typical), then the connection will be maintained for some configurable amount of time waiting form another request from the client to which the connection is allocated.
Whether the request is for a dynamically-generated page or for static content does not really matter with regards to this behavior, however you would end up reusing the connections that the browser has established when downloading the static content from the server in the case where KeepAlive
is on. This could provide better performance in that you don't have the overhead of re-establishing the connection for every single request.
Here is a link to a good article regarding consideration for using KeepAlive
http://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html
Upvotes: 2