Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few reports of people seeing raw html in their browser (instead of their browser interpreting it). It seems to be happen on slow connections. When this happens, if the user reloads the page, the page is interpreted correctly. Are there any server specific things that would cause this to happen? We're using Php 5.1.6 and Apache 2.2.3.

share|improve this question

Two possible scenarios immediately come to mind:

  1. By "raw html", if you mean "interpreted, but unstyled", then this most often happens with pages that are designed strictly with CSS to do all of the styling, because the stylesheet only gets downloaded after the html has been loaded. What you may want to try is to embed some very basic styling inline in the html head section which would at least mean that the page would look "acceptable" until the remaining stylesheet code has been downloaded. And if the stylesheet never actually makes it to the client in the first load, even after waiting patiently, then you may want to increase your connection timeout, which may be preventing the download of the all of the files to display the page correctly.

  2. By "raw html", you really mean "uninterpreted, unstyled plain text with !DOCTYPE and html tags visible", then it could be an even more chronic case of what I described above, or that your PHP script may be set to flushing the response buffer to the client before the html has been completely generated (however, even in this case, most browsers will still make a reasonable attempt to interpret the HTML).

I'll sleep on it and if any more ideas come to mind before anyone else comes up with something more concrete, I'll update my answer accordingly

share|improve this answer
I've seen the issue with CSS often enough, especially on overloaded servers. It takes so long to load the HTML and the images that the browser gives up waiting and you're left with a horribly un-formatted page. – Mark Henderson Aug 21 '09 at 0:28
Reloading the page fixes this issue because the browser has (or at least, should have) cached a lot of the information, leaving the new request to download the missing files (the CSS) – Mark Henderson Aug 21 '09 at 0:28

The usual reason for such a problem, that I've seen working with Drupal which uses PHP, is an error message that happens and is output way early, before the <!DOCTYPE html> or <html> is written in the output. Then the browser is likely to interpret the output as plain text since it did not see a tag with X characters at the start of the document. (It will usually happily skip a certain amount of data, I've see an RSS feed that would start with what would look like 2 random bytes, the first could even be zero, and Firefox was still happy, it would just ignore those bytes!)

One solution to avoid this problem (assuming that is the problem) is to make sure that your production environment does not print out PHP errors to the output buffer. There are settings in php.ini -- although know these can be overridden in PHP code:

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.