diff options
| author | ojacobson <ojacobson@noreply.codeberg.org> | 2025-12-05 20:44:39 +0100 |
|---|---|---|
| committer | ojacobson <ojacobson@noreply.codeberg.org> | 2025-12-05 20:44:39 +0100 |
| commit | 6cd7e6dd5eb001779a83e9e07c7a3c8379b0548f (patch) | |
| tree | 39bb7e26fa7c2861394c5602f10d63deef65c70b /Cargo.toml | |
| parent | 9af71a82ca74fde48283d4e0a0adcd69f4fcb9dd (diff) | |
| parent | a2285c0e91063cf0f07637664c6055acdcacd9a8 (diff) | |
This covers two things:
* For _any_ static asset, send back an `ETag` header based on its content. If the request had an `If-None-Match` header, use that header to instead send back a `Not Modified` response, with no payload, if appropriate, saving the cost of transferring data the client already has.
* For _immutable_ static assets, send back a `Cache-Control` header to allow browsers to replay the response from cache, without making a request, for up to 90 days, saving whole HTTP round-trips.
In practice, startup time is now dominated by the time needed to check whether the user is logged in, and the time needed to satisfy the `/api/boot` request if they are.
"Static" here includes anything that's served in the HTML itself, so things like `/`, `/login`, `/c/:channelid`, and `/me` are all "static," and are all affected by this change even though the logical content of those endpoints also includes data that will vary from user to user and from time to time. All the dynamic data for those responses comes from separate API requests, which don't affect the cacheability of those pages. However, this change is conservative and _does not_ instruct the browser to cache those pages for long periods; it only supports telling the browser that the cached copy they have is fine, via a `Not Modified` response.
This change also includes a minimum Rust version bump, to the recently-released 1.91 - as it uses `Duration::from_hours` to compute the `Cache-Control` header. I could use `Duration::new` or `Duration::from_secs`, but really, working in increments of days from such tiny units is awkward. I'd prefer to use `Duration::from_days`, but it's not stable yet.
Merges asset-etags into main.
Diffstat (limited to 'Cargo.toml')
| -rw-r--r-- | Cargo.toml | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -2,7 +2,7 @@ name = "pilcrow" version = "0.1.0" edition = "2024" -rust-version = "1.90" +rust-version = "1.91" authors = [ "Owen Jacobson <owen@grimoire.ca>", "Kit La Touche <kit@transneptune.net>", @@ -29,6 +29,7 @@ chrono = { version = "0.4.42", features = ["serde"] } clap = { version = "4.5.51", features = ["derive", "env"] } futures = "0.3.31" headers = "0.4.1" +hex = "0.4.3" itertools = "0.14.0" mime = "0.3.17" nix = { version = "0.30.1", features = ["fs"] } |
