Bug 11581 - HTTP 404s generated badly in some cases
Summary: HTTP 404s generated badly in some cases
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Galen Charlton
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 10581
  Show dependency treegraph
 
Reported: 2014-01-17 15:59 UTC by Galen Charlton
Modified: 2022-03-10 03:40 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Galen Charlton 2014-01-17 15:59:05 UTC
There are several scripts that do the following when they want to signal that a resource (usually a MARC record) does not exist:

    print $query->redirect("/cgi-bin/koha/errors/404.pl");

This is not great, because what actually happens is that an HTTP 302 redirect is issued, followed by the 404.  This wastes a bit of time for the user agent, and might be problematic if you let search engines crawl your OPAC.

Better would be doing 

   print $cgi->header( -status => '404 record not found');

or if a more specific message should be displayed, constructing it and calling

  output_with_http_headers $query, $cookie, $error_template->output, 'html', '404 Not Found';

The affected scripts are:

catalogue/showmarc.pl
opac/opac-ISBDdetail.pl
opac/opac-MARCdetail.pl
opac/opac-authoritiesdetail.pl
opac/opac-detail.pl
opac/opac-export.pl
opac/opac-showmarc.pl
opac/opac-topissues.pl
opac/tracklinks.pl
Comment 1 Fridolin Somers 2014-03-25 11:15:03 UTC
Indeed.
I think there should be HTML static pages for all HTTP error codes.
They should be used in both apache configuration and in GCI output (maybe adding methods into C4::Output).
Comment 2 David Cook 2022-03-10 03:38:44 UTC
With Bug 30261, we should be able to use C4::Output::output_error() for any staff interface or OPAC page.
Comment 3 David Cook 2022-03-10 03:40:14 UTC
(In reply to Fridolin Somers from comment #1)
> Indeed.
> I think there should be HTML static pages for all HTTP error codes.
> They should be used in both apache configuration and in GCI output (maybe
> adding methods into C4::Output).

I like the idea of static HTML pages.

I think we've avoided them because we want to use the templating and such for a common look and feel, but I was just thinking... we could generate the static HTML pages during an app build step. I suppose that wouldn't work well for a git deployment though...