1

I am starting to learn about http correctly.

I am working in lamp stack.

On the command line i am requesting a local page which will be served with apache to see the headers that are returned.

curl -i local.testsite

The page i am requesting has no content and i am not setting any headers but there are already a lot of headers sent in the response such as:

HTTP/1.1 200 OK
Date: Thu, 17 Jan 2013 20:28:52 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.4
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html

So if i am not setting these, does apache set these automatically?

2
  • 6
    short answer... yes. Commented Jan 17, 2013 at 20:31
  • Yes, apache sets them automatically. You can set that Server: and X-Powered-By: are not by default. Commented Jan 17, 2013 at 20:31

2 Answers 2

3

Yes Apache is setting those by default. By the way, if you only care about the headers, you should use

curl -I local.testsite

-I returns the headers only (HTTP HEAD request), such that even if you had content on the page you would only get the header.

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

Comments

3

Some are set by PHP:

  • The X-Powered-By header is set by the expose_php INI setting.
  • The Content-Type header is set by the default_mimetype INI setting.

The others are set by Apache:

  • The Server header is set by the ServerSignature directive.
  • The Vary: Accept-Encoding header is usually sent when mod_deflate is enabled.

Date and Content-Length are not configurable as they are part of the HTTP spec. Date is included as a MUST (except under some conditions) and Content-Length as a SHOULD.

See also How to remove date header from apache? and How to disable the Content-Length response header with Apache?.

Comments

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.