summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2023-10-19 20:41:19 +0200
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-10-19 20:41:19 +0200
commit135eff4287c06aff9604a4d0b9ddea1740f6c836 (patch)
tree48dccf09fdb327a1deb126dc89020ea0322b7c5b /modules
parent0daefa86b400efe08245f4f2a386f7341b76b24e (diff)
Avoid caching of rate limited or errored paged
Diffstat (limited to 'modules')
-rw-r--r--modules/cache/cache.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/cache/cache.go b/modules/cache/cache.go
index 10762f9..4750e55 100644
--- a/modules/cache/cache.go
+++ b/modules/cache/cache.go
@@ -64,6 +64,12 @@ func (m *Module) AdaptTransport(t http.RoundTripper) http.RoundTripper {
return resp, err
}
+ // Avoid caching when running into rate limits or
+ // when the page errored.
+ if resp.StatusCode < 200 || resp.StatusCode > 299 {
+ return resp, err
+ }
+
encoded, err := httputil.DumpResponse(resp, true)
if err != nil {
return resp, err