response_cache plugin: rename cached_response? to not_modified?, more accurate

This commit is contained in:
HoneyryderChuck 2025-04-15 11:19:30 +01:00
parent f328646c08
commit 32031e8a03
2 changed files with 4 additions and 3 deletions

View File

@ -37,7 +37,7 @@ module HTTPX
response.status != 206
end
def cached_response?(response)
def not_modified?(response)
response.is_a?(Response) && response.status == 304
end
@ -93,7 +93,7 @@ module HTTPX
return unless response
if ResponseCache.cached_response?(response)
if ResponseCache.not_modified?(response)
log { "returning cached response for #{request.uri}" }
response.copy_from_cached!

View File

@ -6,7 +6,8 @@ module HTTPX
SUPPORTED_VARY_HEADERS: Array[String]
def self?.cacheable_response?: (::HTTPX::ErrorResponse | cacheResponse response) -> bool
def self?.cached_response?: (response response) -> bool
def self?.not_modified?: (response response) -> bool
interface _ResponseCacheOptions
def response_cache_store: () -> Store