From c7002e3ae40a8246162464b200860c8fe5e2aecb Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Fri, 20 Dec 2013 13:00:04 -0500
Subject: [PATCH] Add note to README: only geocode when needed.

---
 README.md | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/README.md b/README.md
index 9261faf0..0a84e6b5 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,17 @@ Geocoder will print warnings if you exceed the rate limit for your geocoding ser
 
     rake geocode:all CLASS=YourModel sleep=0.25
 
+### Avoiding Unnecessary API Requests
+
+Geocoding only needs to be performed under certain conditions. To avoid unnecessary work (and quota usage) you will probably want to geocode an object only when:
+
+* an address is present
+* the address has been changed since last save (or it has never been saved)
+
+The exact code will vary depending on the method you use for your geocodable string, but it would be something like this:
+
+    after_validation :geocode, if: ->(obj){ obj.address.present? and obj.address_changed? }
+
 
 Request Geocoding by IP Address
 -------------------------------
-- 
GitLab