- On the sign
go.cafe.example/menu - In storage
Look up the hostname and the slugmenu. - In the browser
Follow the redirect to this week's menu.
A URL shortener stores a destination under a small, stable key. When someone opens the short URL, the service looks up that key and returns a redirect. Those two requests have different requirements. A café might edit its menu link once a week while hundreds of visitors open the address already printed on its tables.
What should the service store when a link is created?
For the café example, store a row with an owner, a hostname, a slug and the complete destination. Add a unique constraint on the hostname and slug together. Two cafés with different domains can then both use /menu. Two owners sharing the same hostname cannot both claim that address.
Six positions drawn from a case-sensitive alphabet of 62 letters and digits give 62⁶ possible codes, about 56.8 billion. Collisions can occur well before the space fills. For a generated slug, attempt the insert and generate another code if the unique constraint rejects it. For a slug chosen by a person, report that the name is taken and let them pick another. An earlier availability check can be out of date by the time the owner presses Save.
What happens when someone scans the menu?
- The browser requests
https://go.cafe.example/menu. The redirect service reads the row for that host and slug and checks whether it is active. - For an editable menu, the service can return
302 Foundwith aLocationheader pointing to the current destination. Pick a cache policy that reflects how quickly a menu edit must take effect. - The browser follows the destination in a second request. A recorded redirect can tell the café that someone followed the link. Confirm a completed order using the ordering system.
If you cache the mapping at the edge, decide what a visitor may see immediately after an edit or deletion. For example, Cloudflare documents that cached Workers KV reads in another location can take time to reflect a write. Test a menu change from a second location before promising instant updates. See how Workers KV propagates changes and our guide to choosing a redirect status.
What is the maximum length of a URL?
HTTP defines no universal maximum URL length. RFC 9110 recommends support for URIs of at least 8,000 octets in protocol elements. That figure is a baseline for interoperability. The redirect service, proxy and destination can each impose a different limit. An HTTP 414 URI Too Long response means that server declined the request because the target was too long. See RFC 9110 §4.1 and the definition of 414.
Measure the encoded path and query in bytes when checking a request-target limit. A single space written as %20 takes three ASCII bytes. A fragment such as #desserts stays in the browser when it requests the menu, so it can matter to the reader even though it adds no bytes to the server's request target.
A short link solves a printing or message-length problem. The second request still has to fit the menu server's limit. If that server returns 414, shorten the destination itself, for example by saving filter selections under an ID. If the original URL already opens correctly, preserve its query and fragment when saving it and test both the final page and the section the visitor sees.
Three checks before putting the address on a sign
- Two simultaneous creates. Only one owner can acquire a given host and slug. Both callers should get a clear result.
- An edit after a previous visit. Load the original short address, change the menu destination, then open the same short address again. Check the effect of any browser and edge caching.
- A long destination with a fragment. Save the café's real menu URL, including its campaign query and section anchor. Open the short link in a fresh browser and verify the menu section and campaign values.
To use a managed service for this workflow, see the worked 302.sh API example. It creates one link, reads back its destination and explains how to handle a retry.



