Repository navigation
feat: check for newer remote configuration files and add --reload[=config|plugins] flag - #1328
Merged
Merged
Conversation
Remote configuration files (`--config <url>` and `extends`) were cached forever under a hash of the url, so an updated file was never picked up without `dprint clear-cache` or a new url. The cached response is now used while it's fresh according to its caching headers (`Cache-Control: max-age`, `Expires`, `Age`), or for a day when it has none. After that the server is asked for a newer version with `If-None-Match`/`If-Modified-Since` so it can answer 304 Not Modified, and the stale cached copy is used with a warning when the server can't be reached. A redirect chain is only used from the cache when every hop is fresh, otherwise it's requested again from the original url so short-lived redirect targets aren't requested directly. The new global `--reload` flag checks the server right away instead of waiting for the cached copy to expire. Closes #774
dsherret
force-pushed
the
remote-config-cache-revalidation
branch
from
October 10, 2026 21:27
c13be51 to
614f09f
Compare
A plain `--reload` now reloads both remote configuration files and remote plugins, since plugin urls aren't always versioned. `--reload=config` or `--reload=plugins` reloads only one kind, which avoids downloading and setting up every plugin again when only the configuration changed. Each remote plugin is downloaded again at most once per process, so the language server doesn't re-download them every time a config file changes.
--reload flag--reload[=config|plugins] flag
…config Checking for a newer version of a cached remote configuration file now makes a single attempt with a 5 second timeout instead of three attempts with 30 second connect timeouts, since the cached copy is used when it fails. A network that drops packets could otherwise stall formatting for up to 90 seconds. After a failed check the cached response's time is refreshed, so the server is asked again once the response is stale again rather than on every run while offline. Responses marked no-cache are still checked on every run.
…alues The merged completions change tests that every sub command lists the global options last and that the shells can complete the values of flags whose parsers accept any text, so `--reload` joins both.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #774
Remote configuration files (
--config <url>andextends) were cached forever under a hash of the url, so an updated file was never picked up withoutdprint clear-cacheor a new url.Changes
Cache-Control: max-age,Expires/Date,Age), or for a day when it has none.no-cache/no-storeand entries written by older versions (no timestamp) are always checked.If-None-Match/If-Modified-Since. A 304 keeps the cached content and refreshes its headers and timestamp; a 200 replaces it (and the "includes ignored" note is shown again for changed content).--reload[=config|plugins]flag. Plain--reloadchecks the server for newer remote configuration files (a cheap conditional request) and downloads remote plugins again, since plugin urls aren't always versioned.--reload=configand--reload=pluginsdo one kind only. Each remote plugin is reloaded at most once per process, sodprint lsp --reloaddoesn't re-download plugins on every config change. Plumbed throughfmt/check/etc., descendant configs,init, anddprint lsp.,instead of keeping only the last one.cli.md,config.md, and a note inlsp.md.Adds the
httpdatecrate (pinned) for parsingExpires/Date.Tests
Unit tests for the freshness math, resolver tests for fresh hits, 304 revalidation, default expiry, stale fallback, 404, reload, older cache entries without a time,
Agehandling after a 304, and redirect chains. Parser tests for the flag's forms, a CLI test thatdprint fmt --reloadpicks up an updated remoteextendsfile, a CLI test that--reload=pluginsre-downloads a remote wasm plugin while--reload=configdoesn't, a plugin resolver test that a reload happens once per process, and tests that a failed check falls back to the cached copy, defers the next check, and makes a single attempt.Note:
extract_tarball_preserves_exec_bits_via_env_set_permissionsfails locally before and after this change (umask dependent), unrelated to this PR.