add support for res.json and binary data cache #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the module only caches on the use of res.send and has issues with binary files and JSON. This PR should help resolve such issues, but might need a little more work.
Tests now use supertest rather than a spawned process, I found this easier to work with. Let me know your thoughts!
Caching occurs on data passed to res.socket.write, not res.send now. This is is the main update that facilitates support for res.json and binary responses. Cached items now represent the data sent to the response stream too, so this is what gets written to the cache:
One potential issue is the Date header is cached; we might need to work around this?