0

I'm using the function get_headers($url,1) to get headers of the website http://www.sportsmalayalam.com/ The output is as follows. It doesn't have 'Content-Encoding' But when I check the headers of same website through Google Chrome its showing content encoding as gzip.

On running: print_r(get_headers($url,1));

Array ( 
[0] => HTTP/1.1 200 OK 
[1] => Date: Fri, 29 Apr 2016 10:35:20 GMT 
[2] => Content-Type: text/html; charset=UTF-8 
[3] => Connection: close 
[4] => Set-Cookie: __cfduid=d564038ff91bf8887430482dc8a8cf74b1461926119; expires=Sat, 29-Apr-17 10:35:19 GMT; path=/; domain=.sportsmalayalam.com; HttpOnly 
[5] => X-Powered-By: PHP/5.5.9-1ubuntu4.16 
[6] => Set-Cookie: PHPSESSID=empthbjqo968ak1a3cbaa6jr67; path=/ 
[7] => Expires: Thu, 19 Nov 1981 08:52:00 GMT 
[8] => Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
[9] => Pragma: no-cache 
[10] => Link: ; rel="https://api.w.org/" 
[11] => Link: ; rel=shortlink 
[12] => Vary: Accept-Encoding, Cookie 
[13] => Server: cloudflare-nginx 
[14] => CF-RAY: 29b21b47261e2fab-MAA 
)

From Google Chrome: enter image description here

1 Answer 1

4

Compare the Request headers. Chrome is probably sending an Accept-Encoding header that says that a gzipped response is OK while PHP is not. Consequently, the server is responding differently.

Sign up to request clarification or add additional context in comments.

6 Comments

So i have to send request saying i can handle gzip?
Yes. Default is "do not compress", the client needs to explicitly request it.
How can I send that?
cURL is usually your best bet when you want to do anything more than the absolute basics when making HTTP requests.
Is this best way to get server response time of a website?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.