diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-08 18:38:46 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-09 16:12:05 -0500 |
commit | 5ff1e4dc240829b77e24fbf49091dc1c2d351401 (patch) | |
tree | 8cd075c195869cdecba84975fc80eb8719343899 /examples | |
parent | 1828411bba841be3d0fa6d978952a14f2f8f2400 (diff) | |
download | requests-cache-5ff1e4dc240829b77e24fbf49091dc1c2d351401.tar.gz |
Refactor refresh/revalidate behavior
* Rename two (unreleased) options to be more consistent with browser behavior:
* `revalidate()` -> `refresh()`
* `refresh()` -> `force_refresh()`
* Revert `RequestSettings` changes and use just kwargs instead for per-request settings
* Add full type hints back to extra kwargs for `CachedSession.send()`
* Fix a bug in which some kwargs specific to requests-cache could get passed to `requests.Session.send()`
* Use 'must-revalidate' as a temporary header for a user-requested refresh
* Refer to expiration value of 0 more accurately as 'expire immediately' rather than 'do not cache'
* It may potentially be saved and used with revalidation, depending on other headers/settings
* `DO_NOT_CACHE` now has a different value but same effect
* Refer to constants in docs instead of 0, -1, etc.
* Log more details about post-read and pre-cache checks
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/url_patterns.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/url_patterns.py b/examples/url_patterns.py index 0fddb86..c948fef 100755 --- a/examples/url_patterns.py +++ b/examples/url_patterns.py @@ -5,13 +5,13 @@ An example of {ref}`url-patterns` """ from datetime import timedelta -from requests_cache import CachedSession +from requests_cache import DO_NOT_CACHE, NEVER_EXPIRE, CachedSession default_expire_after = 60 * 60 # By default, cached responses expire in an hour urls_expire_after = { 'httpbin.org/image': timedelta(days=7), # Requests for this base URL will expire in a week - '*.fillmurray.com': -1, # Requests matching this pattern will never expire - '*.placeholder.com/*': 0, # Requests matching this pattern will not be cached + '*.fillmurray.com': NEVER_EXPIRE, # Requests matching this pattern will never expire + '*.placeholder.com/*': DO_NOT_CACHE, # Requests matching this pattern will not be cached } urls = [ 'https://httpbin.org/get', # Will expire in an hour |