Skip to content

Commit 020aa45

Browse files
committed
Add "crates.io: Dropping support for non-canonical downloads" blog post
1 parent 59b5bd4 commit 020aa45

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
layout: post
3+
title: "crates.io: Dropping support for non-canonical downloads"
4+
author: Tobias Bieniek
5+
team: the crates.io team <https://www.rust-lang.org/governance/teams/crates-io>
6+
---
7+
8+
## tl;dr
9+
10+
- we want to improve the reliability and performance of crate downloads
11+
- "non-canonical downloads" are blocking these plans
12+
- on 2023-11-20 support for "non-canonical downloads" will be disabled
13+
- cargo users are unaffected
14+
15+
## What are "non-canonical downloads"?
16+
17+
The "non-canonical downloads" feature allows everyone to download the `serde_derive` crate from <https://crates.io/api/v1/crates/serde_derive/1.0.189/download>, but also from <https://crates.io/api/v1/crates/serde-derive/1.0.189/download>, where the underscore was replaced with a hyphen. The same also works vice versa, if the canonical crate name uses hyphens and the download URL uses underscores instead. It even works with any other combination for crates that have multiple such characters (please don't mix them…!).
18+
19+
## Why remove it?
20+
21+
Supporting such non-canonical download requests means that the crates.io server needs to perform a database lookup for every download request to figure out the canonical crate name. The canonical crate name is then used to construct a download URL and the client is HTTP-redirected to that URL.
22+
23+
While we have introduced a caching layer some time ago to address some of the performance concerns, having all download requests go through our backend servers has still started to become problematic and at the current rate of growth will not become any easier in the future.
24+
25+
Having to support "non-canonical downloads" however prevents us from using CDNs directly for the download requests, so if we can remove support for non-canonical download requests, it will unlock significant performance and reliability gains.
26+
27+
## Who is using "non-canonical downloads"?
28+
29+
`cargo` always uses the canonical crate name from the package index to construct the corresponding download URLs. If support was removed for this on the crates.io side then cargo would still work exactly the same as before.
30+
31+
Looking at the crates.io request logs, the following user-agents are currently relying on "non-canonical downloads" support:
32+
33+
- cargo-binstall/1.1.2
34+
- Faraday v0.17.6
35+
- Go-http-client/2.0
36+
- GNU Guile
37+
- python-requests/2.31.0
38+
39+
Three of these are just generic HTTP client libraries. [GNU Guile](https://www.gnu.org/software/guile/) is apparently a programming language, so most likely this is also a generic user-agent from a custom user program.
40+
41+
`cargo-binstall` refers to https://github.com/cargo-bins/cargo-binstall. The maintainer is already aware of the upcoming change and confirmed that more recent versions of `cargo-binstall` should not be affected by this change.
42+
43+
We recommend that any scripts relying on non-canonical downloads be adjusted to use the canonical names from the package index, the database dump, or the crates.io API instead. If you don't know which data source is best suited for you, we welcome you to take a look at <https://crates.io/data-access>.
44+
45+
## What is the plan?
46+
47+
1. **Today:** Announce the removal of support for non-canonical downloads on the main Rust blog.
48+
2. **2023-11-20:** Disable support for non-canonical downloads and return a migration error message instead.
49+
3. **2023-12-18:** Return a regular 404 error instead of the migration error message, allowing us to get rid of (parts of) the database query.
50+
51+
Note that we will still need the database query for download counting purposes for now. We have plans to remove this requirement as well, but those efforts are blocked by us still supporting non-canonical downloads.
52+
53+
If you want to follow the progress on implementing these changes or if you have comments you can subscribe to the corresponding [tracking issue](https://github.com/rust-lang/crates.io/issues/7341). Related discussions are also happening on the [crates.io Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/318791-t-crates-io/topic/non-canonical.20downloads).

0 commit comments

Comments
 (0)