WSWCWaterDataExchange / WestDAAT

Managing the code of the Western States Water Data Access and Analysis Tool (WestDAAT)
https://westdaat.westernstateswater.org/
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

Shorten WestDAAT URLs #294

Open amabdallah opened 1 year ago

amabdallah commented 1 year ago

We need to use a service that shortens the WestDAAT's URL for data-sharing purposes. Here is an example of a URL that was shared with us through feedback submissions. It's getting out of control how long it has become.

Useful resources to look into

  1. https://learn.microsoft.com/en-us/shows/azure-friday/azurlshortener-an-open-source-budget-friendly-url-shortener

  2. https://medium.com/marcus-tee-anytime/create-your-own-url-shortener-host-in-azure-almost-free-for-cloud-infrastructure-a74c9cc29720

WestDAAT long URL example https://u25918979.ct.sendgrid.net/ls/click?upn=vvecQssSvf-2FaCxZpfrW1NzSrcL3gcPfhraL3ROKNkPWKoh-2FKKWBrzMDtSYYzhh-2BcEyrZOBZzbXjo3jZwaE45r0-2FyEWvQwvk23keaVFYLCS3wLBLnJfFellyFXGbk784sWDIcnH4NGIsttqi-2FZ-2B6TLa6KuS5PCTkYkBHu7MeZYcDxzLTl9NYdsGssacDQ4WtXKDLZa7FyUnn1Wi5iNxfj8CjmV2CICvOVXt1YvvcojnqFQhX-2BaJd8-2FTJ-2Fjd81NJ1wyeh-2FscQJDlIbLxrYq2tfISSf3tM-2BVB-2FKy7VLiZ3e-2FaaCg8IqpOonwB-2F9ZXk0jh3WgHqEX8frDb6xK3Td8M1Gs4HsDiJAghNV6SaMx60k8Mz-2BWbywr7mAlxuuFg5zbSMzBZM6aG-2FXAI4YnA0ztTJ0NB87BudSAk5sIkqThb81xuKvNASARDGsQKnj7L833qSVkG2-2B0JecEMIxwA0vpv9p1EKxHLxJzEx7OiLNgOAN-2F3pHRTUmXtnzVqMQlZSP-2BSQvyKoz_uCiIOgIgJtGs5RiWiA58yR-2FRK3CK-2B6-2BDkFmOVDa7Sn0n4C62sIGJ1hqHj-2FCse8WAjNl5L-2B-2B6xBCMIuUrZyvTbhwulG6jXBkAWQCvHmEqOV0QMWUMU7bvepN3gkOFOt8WjylJzRoAz-2BDlynscwjQ1elSwAdbO6nqXzrnl2Tg1rJ9FJmK8dj9-2FoZ-2FDcvyU1YRI8lBJpDJtgg-2F9aCakz-2BCA4U3ReRDvC7xjJMvQzrB9Yqg-3D

Rhipeus commented 1 year ago

A couple of things on this.

First, the URL you just linked is a SendGrid URL that tracks whether the link has been clicked in the email. The actual URL is https://westdaat.westernstateswater.org/?state=N4Ig7gTiBcoM4BcCGCCmcYG0QBUAaIAugDQgAOA9gDYCeVAlgHapYkiNUAm9AYvVWggARFEhigqKeggCunFtADMABgB0ygBwbFpKhUYBzaXIUBaAJwB2VQCYbygGyluEVAGME9fRiXPRABQomBB9LAF8w0gBbJDJxEAAvCgoogBlUADdUKhgARjVLczsAFgdFXKLFB3Ni3SlZeRgVdRtSy0UNXMtinssHWpA9Q2NG6AtrXOKbBwdLAFZHFWLFOcj2Lnp4yU8GhWbNbV19I12Ycdt7JxAXd09vJr9kQODQtY5uAEEPeiyYBAgZKgwkA that is about 60% less than what SendGrid uses for this example. A quick search makes it look like the URL tracking can be turned off if necessary (https://stackoverflow.com/a/43145800/4552551).

Second, URL shorteners don't make the URL shorter despite the name. They provide an alias for a URL. Think of it as a "nickname" for the URL. You can call the URL by a different name, but it will still be long. For instance, when you go to https://aka.ms/networksetup you end up at https://support.microsoft.com/en-us/windows/get-connected-when-setting-up-your-windows-11-pc-50dca26f-40d5-4c3b-853c-e972dafb7e08.

This scenario is not a use case where URL shorteners are typically used. URL shorteners are great when sending a URL in a medium with limited text, like Twitter or SMS messages. However, URL shorteners also add a new dependency to your system that can have outages, reduce system availability, and degrade performance.

When you have many parameters you need to be able to link back to, URLs get long. Even Google ends up with long URLs when you start to add conditions to your search (https://www.google.com/search?q=are+long+urls+bad&lr=lang_en&cr=countryUS&safe=active&tbs=qdr%3Ay%2Clr%3Alang_1en%2Cctr%3AcountryUS&sxsrf=APwXEddFqkBjtsbxiCM83Rk0bE1t_OcKbQ%3A1683731757526&ei=LbVbZPW5H-irqtsP4o2VkAc&ved=0ahUKEwi1hLfKhev-AhXolWoFHeJGBXIQ4dUDCBA&uact=5&oq=are+long+urls+bad&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIECCMQJzIFCAAQgAQyBQgAEIAEMggIABCKBRCGAzIICAAQigUQhgM6CggAEEcQ1gQQsAM6BwgjEIoFECc6CAgAEIoFEJECOhEILhCABBCxAxCDARDHARDRAzoLCAAQgAQQsQMQgwE6CwguEIAEEMcBENEDOgcIABCKBRBDOggIABCABBCxAzoICC4QgAQQsQM6CwguEIAEEMcBEK8BOg0IABCKBRCxAxCDARBDOgsIABCKBRCxAxCDAToECC4QAzoKCAAQgAQQFBCHAjoICAAQFhAeEA86BggAEBYQHkoECEEYAFDpAljlJmCpLmgBcAF4AIABjQGIAa0PkgEEMS4xNpgBAKABAcgBCMABAQ&sclient=gws-wiz-serp). This Google URL is 90% larger than the one from WestDAAT and doesn't cause a problem for Google (and I have no idea why it is so long or what it contains).

There are some ways we can reduce the URL length a little, with some denser data structures and clever URL construction. However, changing filters and site options will result in less flexibility and more development effort in the future. There is a long-term maintenance cost to making such a change.

Long URLs are not a signal of a problem. In your case, they are only a sign that you have a robust filtering system with lots of flexibility.