       query += "/#{options[key] ? ""}"
 
     return query
+
+
+  isKiteValid = (kite) ->
+
+    return no  unless kite?.token?
+
+    [header, body, rest...] = kite.token.split '.'
+
+    return no  unless body
+
+    try
+      {exp} = JSON.parse atob body
+    catch e
+      warn "Failed to parse token:", e
+      return no
+
+    exp = +new Date exp * 1000
+    now = +new Date
+
+    return now < exp
 
 
   signed = (queryString) -> "KITE_#{queryString}"


    queryString = @generateQueryString query
    kite = proxifyTransport kite
    kite.cachedAt = +new Date()

    LocalStorage.setValue (signed queryString), (JSON.stringify kite)


      return @unset query

    if kite.cachedAt?
      warn "[KiteCache] CACHE FOUND WITH OLD STYLE TIMESTAMP, REMOVING..."
      return @unset queryString

    else

      unless isKiteValid kite
        warn "[KiteCache] CACHE FOUND BUT ITS OUTDATED, REMOVING..."
        return @unset queryString

    return kite
