     @requests ?= {} # Maps searchUrls to any outstanding HTTP request for that search engine.
     @cancel searchUrl
 
-    # We cache the results of the most-recent 1000 requests (with a two-hour expiry).
-    # FIXME(smblott) Currently we're caching XMLHttpRequest objects, which is wasteful of memory.  It would be
-    # better to handle caching at a higher level.
-    @requestCache ?= new SimpleCache 2 * 60 * 60 * 1000, 1000
+    # We cache the results of the most-recent 1000 requests with a one-minute expiry.
+    @requestCache ?= new SimpleCache 1 * 60 * 1000, 1000
 
     if @requestCache.has url
       callback @requestCache.get url

  getUrl: (queryTerms) ->
    "http://suggestqueries.google.com/complete/search?ss_protocol=legace&client=toolbar&q=#{Utils.createSearchQuery queryTerms}"

  parse: (xhr, callback) ->
    if suggestions = xhr?.responseXML?.getElementsByTagName "suggestion"
      suggestions =
        for suggestion in suggestions
          continue unless suggestion = suggestion.getAttribute "data"
          suggestion
      callback suggestions
    else
      callback []

# A dummy search engine which is guaranteed to match any search URL, but never produces completions.  This
# allows the rest of the logic to be written knowing that there will be a search engine match.

    # Don't try to complete Javascrip URLs.
    return callback [] if 0 < queryTerms.length and Utils.hasJavascriptPrefix queryTerms[0]

    # Cache completions.  However, completions depend upon both the searchUrl and the query terms.  So we need
    # to generate a key.  We mix in some nonsense generated by pwgen. There is the possibility of a key clash,
    # but it's vanishingly small.
    junk = "//Zi?ei5;o//"
    completionCacheKey = searchUrl + junk + queryTerms.join junk
    @completionCache ?= new SimpleCache 6 * 60 * 60 * 1000, 2000 # Six hours, 2000 entries.
    if @completionCache.has completionCacheKey
      return callback @completionCache.get completionCacheKey

    engine = @lookupEngine searchUrl
    url = engine.getUrl queryTerms
    @get searchUrl, url, (xhr = null) =>
      if xhr?
        callback @completionCache.set completionCacheKey, engine.parse xhr
      else
        callback []

root = exports ? window
root.SearchEngines = SearchEngines
