Recently I noticed that my Chrome browser was having issues displaying some of the web pages on this site. The pages wouldn't load at all or would only load partially.
After some investigating it turned out that those pages were of SSI type, usually having extensions .shtml or .shtm. Such pages could also have other extensions depending on the system configuration.
Figuring out and fixing the problem however took a number of frustrating hours. On this server, Apache has KeepAlive turned on. That means for most browsers the content is sent using chunked transfer encoding and that means the browser and server maintain an open connection for some time as data is passed in. That saves on resources and gives the server more flexibility in data transmission but on the flip side the server needs to calculate and send the content length to the browser for each chunk. Without the correct content length, browsers won't be able to correctly display the page.
After hours of trial and error, I noticed that these pages had an include such as below at their tail end with nothing after that, no newlines, no characters, nothing.
<!--#include virtual="/some_file.inc" -->
The Chrome debugger would show a red failure loading for the page but there was no explanation. cURL however came in handy, displaying this error at the end:
error 18: transfer closed with outstanding read data remaining
That's when the underlying issue revealed itself, sort of. Obviously the server wasn't sending the correct content length or the terminating chunk to the browser causing the failure. The fix came by luck after I added a few characters at the tail end of the file. Turns out that adding a single space or newline character was enough to fix the error.
At this point I have no idea why this flaw exists in the first place and why adding a character at the end of the file fixes the issue. But if you are running into the same problem, try the same solution and see if it helps, and don't underestimate the power of cURL to debug these types of issues.