Rasmus Bang Olesen
Rasmus Bang Olesen

Reputation: 31

Response header - Connection: keep-alive, close

I am trying to up our page speed and the recommendation is to have the Connection: Keep-alive. However, no matter what i try to do i have "keep-alive, close". And I can not find out where the "close" value comes from.

Neither can i remove it. Anyone experience the same thing?

I have this in my .htaccess:

Header set Connection keep-alive

Best regards, Rasmus

Upvotes: 1

Views: 3127

Answers (1)

Vince
Vince

Reputation: 970

Your server appears to have keep-alive disabled for either your account or the whole server to ensure the maximum number of sockets are available at all times Rasmus.

This is of course a double edged sword because most websites typically make between 10-30 requests when pulling down all the resources needed to build a page providing nothing is cached, which is a lot of opening and closing overhead. Even if it needed to pull down 50 additional resources setting it like this:

<ifModule mod_headers.c>
    Header set Connection keep-alive
    Keep-Alive: timeout=5, max=100
</ifModule>

would be more then enough time to get the job done. But I'm sure it's standard practice to disable this feature in order to make sure it's not abused. Just ask your admin if they can hook you up.

My recommendation would be don't worry about the Keep-Alive header, you get way more bang for your buck by making sure your static files are being cached properly anyway. If your admin enables it for you down the road that's great but this is what I put in my .htaccess file to help reduce the number of requests it receives by 60%-80%.

<IfModule mod_expires.c>
    # Enable expiration control
    ExpiresActive On

    # Default expiration: 1 hour after request
    ExpiresDefault "now plus 1 hour"

    # CSS and JS expiration: 1 week after request
    ExpiresByType text/css "now plus 1 week"
    ExpiresByType application/javascript "now plus 1 week"
    ExpiresByType application/x-javascript "now plus 1 week"

    # Image files expiration: 1 month after request
    ExpiresByType image/bmp "now plus 1 month"
    ExpiresByType image/gif "now plus 1 month"
    ExpiresByType image/jpeg "now plus 1 month"
    ExpiresByType image/jp2 "now plus 1 month"
    ExpiresByType image/pipeg "now plus 1 month"
    ExpiresByType image/png "now plus 1 month"
    ExpiresByType image/svg+xml "now plus 1 month"
    ExpiresByType image/tiff "now plus 1 month"
    ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
    ExpiresByType image/x-icon "now plus 1 month"
    ExpiresByType image/ico "now plus 1 month"
    ExpiresByType image/icon "now plus 1 month"
    ExpiresByType text/ico "now plus 1 month"
    ExpiresByType application/ico "now plus 1 month"
    ExpiresByType image/vnd.wap.wbmp "now plus 1 month"
    ExpiresByType application/vnd.wap.wbxml "now plus 1 month"
    ExpiresByType application/smil "now plus 1 month"

    # Audio files expiration: 1 month after request
    ExpiresByType audio/basic "now plus 1 month"
    ExpiresByType audio/mid "now plus 1 month"
    ExpiresByType audio/midi "now plus 1 month"
    ExpiresByType audio/mpeg "now plus 1 month"
    ExpiresByType audio/x-aiff "now plus 1 month"
    ExpiresByType audio/x-mpegurl "now plus 1 month"
    ExpiresByType audio/x-pn-realaudio "now plus 1 month"
    ExpiresByType audio/x-wav "now plus 1 month"

    # Movie files expiration: 1 month after request
    ExpiresByType application/x-shockwave-flash "now plus 1 month"
    ExpiresByType x-world/x-vrml "now plus 1 month"
    ExpiresByType video/x-msvideo "now plus 1 month"
    ExpiresByType video/mpeg "now plus 1 month"
    ExpiresByType video/mp4 "now plus 1 month"
    ExpiresByType video/quicktime "now plus 1 month"
    ExpiresByType video/x-la-asf "now plus 1 month"
    ExpiresByType video/x-ms-asf "now plus 1 month"
</IfModule>

Upvotes: 1

Related Questions