Problem/Motivation

The link rel="alternate" response headers were removed in #2873648: With many languages, content_translation_page_attachments adds too many alternate links to the response headers crashing varnish (503)

The HTTP Link entity-header field provides a means for serializing one or more links in HTTP headers. It is semantically equivalent to the HTML
element.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link

The first bytes in a response are important from a performance perspective. If Link response headers are semantically equivalent to the HTML <link> element, these links should not be available in both the response headers and HTML <link> elements

Apparently Google added support for this to there search engine indexing in 2011. I think the primary use-case was for

giving webmasters yet another avenue to provide a preferred URL for non-text/html content-types such as PDF files

Source: https://moz.com/blog/how-to-advanced-relcanonical-http-headers

Because it’s relatively easy to implement rel=canonical tags in a page’s HTML, it’s rare to find canonical links sent as part of a page’s HTTP response. However, it’s always worth double-checking the page’s HTTP headers for canonical links, especially if you see unusual indexing and ranking issues on a website.

Source: https://searchengineland.com/the-ultimate-guide-to-http-status-codes-and...

Proposed resolution

Remove redundant Link canonical/shortlink response headers

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork drupal-3266589

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idebr created an issue. See original summary.

idebr’s picture

Issue summary: View changes
idebr’s picture

Status: Active » Needs review
FileSize
0 bytes

Attached patch removes redundant Link canonical/shortlink response headers

Wim Leers’s picture

Issue tags: +front-end performance

0 byte patch 🤓

idebr’s picture

FileSize
1.93 KB

Attached patch has bytes and removes redundant Link canonical/shortlink response headers

mfb’s picture

Added draft change record @ https://www.drupal.org/node/3267018

longwave’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Needs review » Reviewed & tested by the community

Just spotted this in a site I am debugging that has a large number of HTTP headers, agree that these are duplicated with <link> tags and so should be removed.

  • catch committed 9caa48f on 10.0.x
    Issue #3266589 by idebr, mfb, longwave: Remove redundant Link canonical/...
  • catch committed 3215320 on 10.1.x
    Issue #3266589 by idebr, mfb, longwave: Remove redundant Link canonical/...
  • catch committed 41d155e on 9.5.x
    Issue #3266589 by idebr, mfb, longwave: Remove redundant Link canonical/...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Agreed these are redundant, and it makes more sense to send them as part of the response body than the headers.

Committed/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!

longwave’s picture

xjm’s picture

Status: Fixed » Needs work

The release note could use some work to answer the question "What does this mean to me?" for a site owner or module developer. The release note should describe what it was before, what changed, what the consequences of the change are, and what a site owner or module developer might need to do as a result. It should also link the change record. Thanks!

catch’s picture

Issue summary: View changes
Status: Needs work » Fixed

I've added a sentence, which says that it should have no effect at all + linked the change record, agreed it's good to spell that out.

xjm’s picture

If it has no effect at all, why would it need to be in the release notes?

catch’s picture

Issue summary: View changes
Issue tags: -9.5.0 release notes, -10.0.0 release notes

Yeah that's a fair point. There's an infinitesmal chance that someone has a custom bot somewhere that reads the headers and not the HTML head, but there's no reason to write something like that, and it's not anything that site owners could do anything about anyway. Untagging and removing the release note. We can keep the CR.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.