Skip to content

fix: resolve relative URLs against base_url in cache keys - #425

Merged
JWCook merged 1 commit into
requests-cache:mainfrom
alessio-locatelli:issue-422
Oct 7, 2026
Merged

JWCook merged 1 commit into
requests-cache:mainfrom
alessio-locatelli:issue-422

Conversation

@alessio-locatelli

Copy link
Copy Markdown
Collaborator

Closes #422

Cache keys were built from the URL as passed to the request, before
aiohttp resolves a relative URL against the session's `base_url`. So
`GET /x` got the same key for every base URL, and sessions sharing a
cache backend returned each other's cached responses.

Requests, `has_url()`, and `delete_url()` now resolve relative URLs
first. `ClientSession._build_url()` isn't used for this because it's
private and, in older aiohttp versions, asserts that the URL is
relative whenever `base_url` is set.

Cache entries saved for relative URLs won't be found after upgrading.

Fixes requests-cache#422
@alessio-locatelli

alessio-locatelli commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

There are no other bugs I am aware of, and no pending PRs. Please proceed with the 0.15.0 release once you rebase and merge this.

@JWCook
JWCook merged commit 85be22a into requests-cache:main Oct 7, 2026
8 checks passed
@JWCook

JWCook commented Oct 7, 2026

Copy link
Copy Markdown
Member

Done! v0.15.0 is out on PyPI now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache keys ignore base_url, so sessions with different base URLs share cached responses

2 participants