Your definition of "invalid" is incomplete.
-
"Formally valid" is easy.
-
404 is relatively easy.
-
What about temporary failures? "Site maintenance, please check back in 5 minutes"?
-
"Bandwidth exceeded" - invalid for the rest of the month, then valid again?
-
What about corporate intranets - valid inside, invalid outside?
-
"This content is not available in your country?"