Use Persistent Connections (keep-alive)
|
07-16-2010, 03:28 AM
Post: #1
|
|||
|
|||
Use Persistent Connections (keep-alive)
Hi Folks;
I'm trying to optimize my site (as best I can :-) and I keep seeing this issue reported; Use persistent connections (keep alive): FAILED - http://www.askmarvin.ca/forums/index.php I don't much about keep-alives but it seems that they are working for images - it's just the .php file itself ? I'm running IIS 5.0 w/PHP 5.2.5 & the IIS ISAPI module. Try as I might I can't seem to find any info on how to enable keep-alives with PHP on IIS 5.0 - does anyone know? |
|||
07-16-2010, 03:39 AM
Post: #2
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Hey Marvin,
I had the same problem before with my coldfusion pages when I started to use GZIP for the main document. You need to set a php header for content length. For coldfusion I did something like this: Code: <cfsavecontent variable = "raw"> Hope this helps. Sincerely, Travis Walters |
|||
07-16-2010, 04:10 AM
Post: #3
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Hi Travis!
I thought it would be a matter of changing a setting on the web server but it looks like it requires a programmatic approach - that makes it a bit beyond my reach ![]() I wonder if it's even causing much of a performance hit - I believe keep-alives are working for everything else but php. |
|||
07-16-2010, 04:21 AM
Post: #4
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Hey There,
If you are on a windows server, try going to your internet information settings (IIS) manager. If you right click your website, click properties, and make sure enable http keep-alives is checked. I am not really experienced on unix or linux servers so if you are using one of those, perhaps someone else on here can help. Sincerely, Travis Walters |
|||
07-16-2010, 04:37 AM
Post: #5
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Hi Travis;
It's Windows 2000 / IIS 5.0 and keep-alives are enabled on the server and on the specific website. Maybe I'm chasing a ghost (I don't really know what I'm doing) because this is what the requests look like which would seem (to me) to indicate that keep-alives are enabled? Request 1: URL: http://www.askmarvin.ca/forums/index.php Host: http://www.askmarvin.ca IP: 70.66.128.238 Location: Parksville, Canada* Error/Status Code: 200 Start Offset: 0 s DNS Lookup: 159 ms Initial Connection: 75 ms Time to First Byte: 150 ms Content Download: 215 ms Bytes In (downloaded): 7.2 KB Bytes Out (uploaded): 0.5 KB Request Headers: GET /forums/index.php HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-shockwave-flash, */* Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; PTST 2.219; PTST 2.219) Host: http://www.askmarvin.ca Connection: Keep-Alive Response Headers: HTTP/1.1 200 OK Connection: close Transfer-Encoding: chunked Date: Thu, 15 Jul 2010 18:30:36 GMT Content-type: text/html X-Powered-By: ASP.NET X-Powered-By: PHP/5.2.5 Set-Cookie: session_id=f8e1eeda8d6fdea15e256c35eec13352; path=/forums/; domain=.askmarvin.ca Content-Encoding: gzip Vary: Accept-Encoding Request 2: URL: http://www.askmarvin.ca/forums/style_images/AskMarvin/topleft.jpg Host: http://www.askmarvin.ca IP: 70.66.128.238 Location: Parksville, Canada* Error/Status Code: 200 Start Offset: 0.545 s Initial Connection: 65 ms Time to First Byte: 96 ms Content Download: 0 ms Bytes In (downloaded): 1.4 KB Bytes Out (uploaded): 0.5 KB Request Headers: GET /forums/style_images/AskMarvin/topleft.jpg HTTP/1.1 Accept: */* Referer: http://www.askmarvin.ca/forums/index.php Accept-Language: en-us UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; PTST 2.219; PTST 2.219) Host: http://www.askmarvin.ca Connection: Keep-Alive Cookie: session_id=f8e1eeda8d6fdea15e256c35eec13352 Response Headers: HTTP/1.1 200 OK Connection: Keep-Alive Content-Length: 1110 Expires: Fri, 15 Jul 2011 18:30:36 GMT Date: Thu, 15 Jul 2010 18:30:36 GMT Content-Type: image/jpeg ETag: "65db83521916cb1:92e" X-Powered-By: ASP.NET Cache-Control: max-age=31536000 Accept-Ranges: bytes Last-Modified: Sun, 27 Jun 2010 16:53:52 GMT Content-Encoding: gzip Vary: Accept-Encoding |
|||
07-16-2010, 04:47 AM
Post: #6
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Notice in Request #1 the "Content-Length" value is not there while in Request #2 it is.
I believe that is the key to getting your keep alive working for the main document. I am just not sure how to do it short of programming. How do you have the main document being gzipped? Is that programmatic or do you have a setting somewhere? |
|||
07-16-2010, 05:25 AM
Post: #7
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
It's done programmatically and turned off in php.ini. I think this is the code that turns it on;
PHP Code: //--------------------------------------- I don't know if that helps as this is mostly above my head ![]() |
|||
07-16-2010, 07:16 AM
Post: #8
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Here is a wild guess but it looks like there is a function somewhere called do_headers().
You might be able to add some sort of line there like: Code: $len = filesize($filename); I found that on a quick Google search. My PHP ability is a bit limited. |
|||
07-18-2010, 03:48 AM
(This post was last modified: 07-18-2010 04:39 AM by marvin-miller.)
Post: #9
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
(07-16-2010 04:47 AM)green-watch.org Wrote: Notice in Request #1 the "Content-Length" value is not there while in Request #2 it is. I think you're on the right track - I found this on the Internet and, while you probably already know it it, I posted it for my own (and future) reference. It's probably going to be handy for other IIS users who encounter this. Quote:"What's causing IIS to send Connection:Closed in the HTTP headers even though the browser requests Connection:Keep-Alive? from Forcing Keep-Alive Sessions (WindowsIT Pro) Following up on this article I found this (How to enable chunked transfer encoding with IIS). The important part about it seems to be this; Send Chunked Data in ISAPI Programming In Internet Server Application Programming Interface (ISAPI) programming, if you want to send chunked data, add a "Transfer-Encoding: chunked" header, and then send the correctly formatted chunked stream by using InternetWriteFile: Quote:POST / HTTP/1.1 Is that why you coughed up this bit of code?; PHP Code: $len = filesize($filename); After looking through the code for my site it seems that the location where the headers are set globally is here; PHP Code: //------------------------------------------- |
|||
07-18-2010, 10:04 PM
Post: #10
|
|||
|
|||
RE: Use Persistent Connections (keep-alive)
Yes that is why I suggested that piece of code that I found.
It looks like your do_headers() is some sort of global function that you might be able to add the content length easily. However, I am not an advanced or even intermediate PHP programmer so my code might be a bit off. I just found it through Google. If nobody here knows the answer, you might find a PHP forum through Google and ask on there how to set a PHP header for content-length and see if that influences the results on webpagetest any. I think it should if the content length is set correctly. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)