@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Set "preconnect" HTTP header when "security.alternate-file-domain" is set

Summary:
When a CDN or alternate file domain is configured, reduce perceived latency by resolving DNS and establishing a connection.

See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preconnect and https://we.phorge.it/book/phorge/article/configuring_file_domain/

Closes T15859

Test Plan:
1. Set http://phorge.localhost/config/edit/security.alternate-file-domain/ via `./bin/config set "security.alternate-file-domain" "https://whatever.example.com/"`
2. Open the "Network" tab in your web browser's "Developer Tools" and go to http://phorge.localhost/
3. Check under "Headers" that "Response Headers" includes the new header `Link: <https://whatever.example.com/>; rel="preconnect"`.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: avivey, speck, l2dy, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15859

Differential Revision: https://we.phorge.it/D25694

+5
+5
src/aphront/response/AphrontHTMLResponse.php
··· 6 6 $headers = array( 7 7 array('Content-Type', 'text/html; charset=UTF-8'), 8 8 ); 9 + $cdn = PhabricatorEnv::getEnvConfig('security.alternate-file-domain'); 10 + if ($cdn) { 11 + $headers[] = array('Link', '<'.$cdn.'>; rel="preconnect"'); 12 + } 13 + 9 14 $headers = array_merge(parent::getHeaders(), $headers); 10 15 return $headers; 11 16 }