Save responses to cache

This commit is contained in:
Tobe O 2018-04-01 21:40:08 -04:00
parent 4c37659cc7
commit 46c4e9006a

View file

@ -65,7 +65,12 @@ class ResponseCache {
// If the cache entry should be invalidated, then invalidate it. // If the cache entry should be invalidated, then invalidate it.
invalidate(req.uri.path); invalidate(req.uri.path);
} }
// Save the response.
_cache[req.uri.path] = new _CachedResponse(res.headers, res.buffer.toBytes(), now);
} }
return true;
} }
} }
@ -89,5 +94,5 @@ class _CachedResponse {
final List<int> body; final List<int> body;
final DateTime timestamp; final DateTime timestamp;
_CachedResponse({this.headers, this.body, this.timestamp}); _CachedResponse(this.headers, this.body, this.timestamp);
} }