In opac/tracklinks.pl we use a simple redirect to send the user on to the actual URL, after tracking: print $cgi->redirect($uri); This sends a "302 Moved Temporarily" to the browser as a default. One of our clients had some SEO work done on their websites, and one of the recommendations was to use "301 Moved Permanently" instead. This makes some sense, the URLs we redirect to do not change very often, I guess. According to https://metacpan.org/pod/CGI#Generating-a-redirection-header, the solution is to change the call to redirect() thusly: print $q->redirect( -uri => $uri, -status => '301 Moved Permanently' ); Patch coming.
Created attachment 113588 [details] [review] Bug 27009 - Use 301 to redirect from tracklinks.pl The default for the tracklinks.pl redirect is "302 Moved Temporarily". It makes more sense to use "301 Moved Permanently". To test: 1. Set TrackClicks = Track 2. Make sure you have a MARC record with an external link in 856$u 3. In the OPAC, click on the link and use e.g. Developer tools to check on the HTTP status code sent by tracklinks.pl. It will be 302. 4. Apply this patch and restart all the things 5. Click on the external link in the OPAC again. The status code should now be 301.
Created attachment 113647 [details] [review] Bug 27009 - Use 301 to redirect from tracklinks.pl The default for the tracklinks.pl redirect is "302 Moved Temporarily". It makes more sense to use "301 Moved Permanently". To test: 1. Set TrackClicks = Track 2. Make sure you have a MARC record with an external link in 856$u 3. In the OPAC, click on the link and use e.g. Developer tools to check on the HTTP status code sent by tracklinks.pl. It will be 302. 4. Apply this patch and restart all the things 5. Click on the external link in the OPAC again. The status code should now be 301. Signed-off-by: David Nind <david@davidnind.com>
HTTP 301 responses are cacheable by default, which means some browsers can cache the redirect indefinitely, and can redirect without doing the request to tracklinks.pl once it is cached. I believe it is not the intended behaviour for a script that is supposed to track redirects. I don't know what are the modern browsers caching strategies for those redirects, but just to be sure, I think we should add a header 'Cache-Control: no-store'.
Changing status to Failed QA to get feedback