Cash rules everything around me, C.R.E.A.M! Get the money, dolla dolla bill ya'll
Cashed is an in memory compress once serve many times static file server with propper support for Etags and 304 responses.
Compressing static resources is an imporant optimization for serving resources as fast as possible. The problem with compression in node.js is that it's a CPU bound activity, meaning while the asset is being compressed the event loop is temporarily blocked. Also, it just doesn't make sense to have to compress the same resource every time it's requested as the same result will be produced every time.
When a request is received for a static resource by
cashed and we don't
have a matching file/compression-algo payload stashed in memory we generate
one and push the results through the response stream and stash them in
memory as well. So all subsequent requests for the same static resource will
be served pre-compressed and directly from memory. Cashed currently supports
Gzip and Deflate compression algorithms and caches them both independently.
As a free side effect of using
filed we also get Etag based caching for
free. When an Etag cache it is detected by
cashed the resulting HTTP
payload the HTTP client will receive in the 304 response is typically
~53 bytes, because the resource doesn't have to be sent to the client, just
some cache hit headers and the 304 status code.