Add opt-in response caching with --cache-ttl and a cache command#288
Open
jongio wants to merge 1 commit into
Open
Add opt-in response caching with --cache-ttl and a cache command#288jongio wants to merge 1 commit into
jongio wants to merge 1 commit into
Conversation
Cache successful GET responses on disk and serve them until the entry is older than --cache-ttl. A cache hit skips both the network call and token acquisition, which speeds up repeated reads of the same resource in scripts and CI. - --cache-ttl <duration> turns caching on for a single GET (repeat runs still measure latency and always hit the network). Only 2xx responses are stored. - --no-cache bypasses the cached entry and refreshes it with a fresh response. - azd rest cache path prints the cache directory; azd rest cache clear removes all entries. Entries are keyed by method, final URL, and resolved scope, stored under the user cache directory with owner-only permissions (0700 dir, 0600 files). An invalid --cache-ttl exits with code 2 before any request work. A corrupt or expired entry is treated as a miss, and a cache write failure is a note rather than a request failure. Closes #283 Co-authored-by: Copilot App <[email protected]>
Contributor
|
🚀 Website Preview Your PR preview is ready! 📎 Preview URL: https://jongio.github.io/azd-rest/pr/288/ This preview will be automatically cleaned up when the PR is closed. |
Contributor
🚀 Test This PRA preview build ( One-Line Install (Recommended)PowerShell (Windows): iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-rest/main/scripts/install-pr.ps1) } -PrNumber 288 -Version 0.5.0-pr288"Bash (macOS/Linux): curl -fsSL https://raw.githubusercontent.com/jongio/azd-rest/main/scripts/install-pr.sh | bash -s 288 0.5.0-pr288UninstallPowerShell (Windows): iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-rest/main/scripts/uninstall-pr.ps1) } -PrNumber 288"Bash (macOS/Linux): curl -fsSL https://raw.githubusercontent.com/jongio/azd-rest/main/scripts/uninstall-pr.sh | bash -s 288Build Info:
|
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.
What
Adds opt-in on-disk response caching for
GETrequests, plus acachecommand to inspect and clear the store. This closes the gap with restish, which caches responses whileaz restandazd restre-fetch every time.Flags
--cache-ttl <duration>: cache successfulGETresponses and serve them until the entry is older than the window (30s,5m,1h).0disables caching. Only 2xx responses are stored, and only for a single request (--repeat 1). A cache hit skips token acquisition.--no-cache: ignore any cached entry, send the request, then refresh the cache with the new response.Command
azd rest cache path: print the cache directory.azd rest cache clear: delete all cached responses.Behavior
--cache-ttlexits with code 2 before any request work happens.Tests
--no-cacherefresh, non-2xx not cached, non-GET not cached, invalid TTL exit code 2.cache path/cache clearcommand output.Reference docs updated in
web/src/pages/reference.astro.Closes #283