Spring Sale! Save 30% on all books w/ code: PLANET24
Web Dev + WordPress + Security

Important Note for Your Custom Error Pages

Just a note to web designers and code-savvy bloggers: make sure your custom error pages are big enough for the ever-amazing <cough> Internet Explorer browser. If your custom error pages are too small, IE will take the liberty of serving its own proprietary web page, replete with corporate linkage and poor grammar.

How big, baby?

Well, that’s a good question. In order for users of Internet Explorer to enjoy your carefully crafted custom error pages, they need to exceed 512 bytes in size. Using proper doctype markup, your custom pages should include more than around 10 lines (roughly) of additional markup and/or content. A good rule of thumb is to throw down at least a couple of decent-sized chunks of code. If you are going for a minimalist set of custom error pages and need a way to increase overall page size, you can always add a paragraph or two of good ‘ol Lorem Ipsum text as a comment in the markup:

<!-- Just for you, Microsoft! 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque scelerisque. Donec euismod. Mauris eget pede es vel est tristique adipiscing. Integer in sem a enim molestie elementum. Curabitur elementum, nisl eu dapibus dapibus, libero tortor tincidunt quam, in facilisis arcu lacus ut diam. Nam ultricies felis sed felis. Integer interdum. Quisque iaculis porttitor magna. Fusce aliquet. Nulla felis dui, pulvinar at, rutrum in, fermentum eu, metus. Praesent purus nunc, porta vel, sodales id, fermentum eget, massa.
-->

Um, why?

Don’t ax me why Microsoft chose to implement this bizarre functionality in their browsers. They probably had a reason for doing so. As for why 512 bytes is useful to remember as a minimum page size for IE, let’s have a look at the following table, which shows the file sizes of IE’s default error pages for various HTTP error codes:

Code Description File Size
400 Bad Request > 512 bytes
403 Forbidden > 256 bytes
404 Not Found > 512 bytes
405 Method Not Allowed > 256 bytes
406 Not Acceptable > 512 bytes
408 Request Time-out > 512 bytes
409 Conflict > 512 bytes
410 Gone > 256 bytes
500 Internal Server Error > 512 bytes
501 Not Implemented > 512 bytes
505 HTTP Version Not Supported > 512 bytes

Apparently, IE is programmed to use these default pages if something bigger is unavailable — even if it is explicitly specified elsewhere. In other words, if Microsoft encounters a non-IE error page that is bigger than their own, it is recognized as a legitimate, deliberate alternative and thusly served. As to why Microsoft chose “file size” as the deciding factor, we may never know.

As we may see, there are actually several different minimum error-page file sizes, not just one. Nonetheless, the differences are practically negligible and hardly worth memorizing. Thus, we simply use the largest value as the minimum, and the others are automatically included. So, by ensuring that each of our various custom error pages is at least 512 bytes in size, we ensure that IE recognizes and serves them instead of their own, sad versions.

As always, any additional insight is greatly appreciated! :)

About the Author
Jeff Starr = Fullstack Developer. Book Author. Teacher. Human Being.
Wizard’s SQL for WordPress: Over 300+ recipes! Check the Demo »

14 responses to “Important Note for Your Custom Error Pages”

  1. Thanks for this great info before i spend several hours for debugging my whole application

  2. Stacy:

    Try adding the following to the top of the 404.php file:

    <?php ob_start(); ?>
    <?php header("HTTP/1.1 404 Not Found"); ?>

    I found this solution from a Canadian website, and it worked out for me.

    http://wpcanada.ca/2008/03/20/ie-and-custom-error-pages/

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
Digging Into WordPress: Take your WordPress skills to the next level.
Thoughts
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Note to self: encrypting 500 GB of data on my iMac takes around 8 hours.
Getting back into things after a bit of a break. Currently 7° F outside. Chillz.
2024 is going to make 2020 look like a vacation. Prepare accordingly.
First snow of the year :)
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.