Migration

Re-mapping cached results after a provider switch

Caching is a sensible and common optimization for geocoding, since the same addresses often get looked up repeatedly and there is little reason to pay for or wait on a fresh lookup every time. But a cache built up over months or years against one provider's results creates a specific problem during a migration: what happens to all that cached data once the provider behind it changes.

The safest general position is that cached results tied to a specific provider's coordinate precision, address formatting conventions, or match confidence should not be silently treated as equivalent to results from a new provider, even if the new provider is generally accurate. Coordinate precision in particular can differ subtly between providers, and an application that stores a cached latitude and longitude to several decimal places may be relying on precision characteristics specific to whichever provider originally produced that number.

A few practical approaches, in roughly increasing order of thoroughness:

  • Tag cached entries with their source provider. If your cache does not already record which provider produced a given cached result, add that field before migrating, so you can distinguish old and new entries going forward rather than treating the whole cache as one undifferentiated pool
  • Set an expiration on legacy cached entries. Rather than invalidating the entire cache at once, which can cause a sudden spike in live requests to the new provider, let old entries expire naturally on whatever TTL your cache already uses, so the transition to fresh, new-provider results happens gradually
  • Selectively re-verify high-value cached entries. For addresses that matter disproportionately, a primary business location, a frequently used shipping address, it is worth an explicit re-lookup against the new provider rather than waiting for a natural cache expiration, since these are the entries where a subtle discrepancy would be most noticed

Because forward geocoding results in particular can vary in exact formatting and precision between providers, this is a case where testing a meaningful sample of your actual cached addresses against the new provider before fully switching is more valuable than testing with synthetic or hand-picked test addresses. Real cached data reflects your real usage patterns, edge cases and all.

My Geocode's compatibility hosts return data through the same field structure as the original provider, so any code that reads and stores cache entries by field name should not need restructuring during a migration, only the values themselves may differ slightly between providers for a given address. Quota headers present on every response, X-Quota-Used and X-Credits-Remaining among them and documented at /docs/rate-limits/, are also worth factoring into a cache invalidation plan, since a sudden wave of cache misses translates directly into a spike in request volume, and pacing that wave against your quota is a small but genuinely useful piece of migration planning.

Treating cache migration as its own small project, rather than an afterthought that happens automatically once the provider switch is live, avoids a class of subtle data quality issues that are much harder to diagnose after the fact than to plan for up front.