Showing a 404 on missing media (e.g. PDF)

Hi all,

I am trying to understand how 404 message appears for missing media, like PDFs. Handling missing pages is clear, and it works but I am not seeing the same thing when looking for media that is missing. Here is an example:

https://archive.theglobalfund.org/media/234wsd/test.pdf

The server does not show the 404 page, but also when looking at the status code under Network (Dev Tools) it shows “(failed) net::ERR_HTTP_RESPONSE_CODE_FAILURE”.

If you remove .pdf from the link, it works fine:

https://archive.theglobalfund.org/media/234wsd/test

Does anyone have any ideas how to handle this?

Thank you,
Genc

Hi,

There are two concepts here:

Q: Why does the server send a 404 error with no content for missing files?
A: Most web servers would have an instruction saying something like “any request ending with a known file type should always exist on disk, and if not, return an empty response early”. So the request will never hit Umbraco, and therefore never hit the not-found mechanisms in Umbraco.

Q: Should you show a 404 page when files are not found at all?
A: No, this is an anti-pattern. If you send HTML out when a static file is not found, and the item happens to be embedded somewhere (like an tag), the browser will not know what to do.

I think you are good, the error looks all right.

1 Like

Thank you Jacob, that makes sense. I do however have a sense that there is an underlying problem because network under Dev Tools does not capture a 404 code but “(failed) net::ERR_HTTP_RESPONSE_CODE_FAILURE” instead. I see that Umbraco.com does the same so I guess this is by design.

Because it is not a pure 404 I am getting a feeling that Google is not updating its index as a result. Thx for the response and solution to this inquiry.