1

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.

2 Answers 2

1

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

2
  • 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. Aug 21, 2009 at 0:28
  • 1
    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) Aug 21, 2009 at 0:28
1

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:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .