diff --git a/lib/geocoder/lookups/base.rb b/lib/geocoder/lookups/base.rb
index e87dd63433c83110ff34f741f706756b3c01c774..cbf3f8287cb3e92a0aa5fd8361328a29733ef38f 100644
--- a/lib/geocoder/lookups/base.rb
+++ b/lib/geocoder/lookups/base.rb
@@ -146,15 +146,16 @@ module Geocoder
         timeout(Geocoder::Configuration.timeout) do
           url = query_url(query, reverse)
           uri = URI.parse(url)
-          unless cache and response = cache[url]
+          unless cache and body = cache[url]
             client = http_client.new(uri.host, uri.port)
             client.use_ssl = true if Geocoder::Configuration.use_https
-            response = client.get(uri.request_uri).body
-            if cache
-              cache[url] = response
+            response = client.get(uri.request_uri)
+            body = response.body
+            if cache and (200..399).include?(response.code.to_i)
+              cache[url] = body
             end
           end
-          response
+          body
         end
       end