[openstreetmap/openstreetmap-website] If http2 supported, disable tile domain sharding (#2584)

Andy Allan notifications at github.com
Fri Apr 10 09:39:14 UTC 2020


@gravitystorm commented on this pull request.

I realise that this is going upstream, and for the variable naming etc they will have their own preferences. But here's a small review anyway, and I think the url changes are worth highlighting.

> @@ -1,8 +1,25 @@
 L.OSM = {};
 
+var h2 = false;

I'd choose `http2` as the variable name, for clarity. I think `h2` is a bit obscure.

> @@ -1,8 +1,25 @@
 L.OSM = {};
 
+var h2 = false;
+// tile.openstreetmap.org supports http/2 where sharding makes no sense.
+// Use only one subdomain if we're using http/2
+if (
+    (window.performance && window.performance.getEntries      && performance.getEntries()[0].nextHopProtocol == 'h2') ||
+    (window.performance && performance.timing.nextHopProtocol && performance.timing.nextHopProtocol          == 'h2') ||
+    (window.chrome      && window.chrome.loadTimes            && window.chrome.loadTimes().connectionInfo    == 'h2')
+) {
+    h2 = true;
+}
+
+if (h2) {
+    var osmtileurl = 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png';

I recommend using `tile.openstreetmap.org` if you don't need the abc subdomains, since the `a` is just an artifact of the load distribution that this patch moves away from.

> @@ -44,9 +61,14 @@ L.OSM.HOT = L.OSM.TileLayer.extend({
   }
 });
 
+if(h2) {
+    var osmgpsurl = 'https://gps-a.tile.openstreetmap.org/lines/{z}/{x}/{y}.png';

As above - `gps.tile.openstreetmap.org` is sufficient

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2584#pullrequestreview-391330068
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200410/a79d0d80/attachment.htm>


More information about the rails-dev mailing list