tags:

views:

46

answers:

2

So I just now learned of the X-Robots-Tag which can be set as part of a server response header. Now that I have learned about this particular field, I am wondering if there are any other specific fields I should be setting when I output a webpage via PHP? I did see this list of responses, but what should I be manually setting? What do you like to set manually?

Restated, in addition to...

header('X-Robots-Tag: noindex, nofollow, noarchive, nosnippet', true);

...what else should I be setting?

Thanks in advance!

A: 

These are headers from Stackoverflow (this page), so the answer is, probably none. You don't want your site indexed (noindex)?

Status=OK - 200
Cache-Control=public, max-age=60
Content-Type=text/html; charset=utf-8
Content-Encoding=gzip
Expires=Tue, 28 Sep 2010 01:23:00 GMT
Last-Modified=Tue, 28 Sep 2010 01:22:00 GMT
Vary=*
Set-Cookie=usr=t=&s=; domain=.stackoverflow.com; expires=Mon, 28-Mar-2011 01:22:00 GMT; path=/; HttpOnly
Date=Tue, 28 Sep 2010 01:21:59 GMT
Content-Length=6929

This header comes handy to me. Characters are displayed correctly, even if meta tag is missing.

Content-Type: text/html; charset=utf-8
Webarto
I wouldn't say "comes handy", I'd say that's the one header you absolutely *need to* send. A document without meta information about its encoding is irresponsible these days.
deceze
This is header, meta tag is in <head>, of course you need to set it. But if you create document (blank php file with some utf8 chars) you need to send this header previously, so browser can decode it properly. There is no need to send this header if you declared it in HTML, that's way I said "comes handy", personally I always use it.
Webarto
A: 

You don't necessarily need to set any of them manually, and I don't send any unless absolutely necessary: most response headers are the web server's job, not the application's (give or take Location & situational cache-related headers).

As for the "X-*" headers, the X implies they aren't "official," so browsers may or may not interpret them to mean anything - like, you can add an arbitrary "X-My-App-Version" header to a public project to get a rough idea of where people are using it, but it's just extra info unless the requester knows what to do with it.

I think most X-headers are more commonly delivered via HTML as meta tags already. For example, <meta name="robots" content="noindex, nofollow, (etc)" />, which does the same as X-Robots-Tag. That's arguably better handled with the meta tag version anyway, since it won't trip over output buffering as header() can do, and it will be naturally cached since it's part of the page.

tadamson
My webpage is updated by myself probably once a month. What, if any, cache header information should I be setting?
TroubledGuym
Manually setting cache headers is more for when you want to force a page to *not* cache. Check the `Expires` header in a page from your web server (via Firebug, or telnet to port 80, etc) to see what yours defaults to - chances are it's just fine.
tadamson