In trying to be a pragmatic programmer, I'm trying to work out a caching strategy for services and rates returned from the UPS and USPS apis.
My first thought would be to store following:
- postal code (normalized, no spaces, simply as a key)
- carrier
- weight
- service
- cost
- transit time
- country code (ISO 3166-1 alpha-2)
My primary goal is to set a short timeout for the API call, and fail over to cached data. For situations where "estimated" rates are acceptable (ex: shipping calculator on a shopping cart), I plain to use the cached data first.
EDIT I fully intend to prime this cache on a regular basis from existing user data.