cloudhead/node-static — pull request #36 by dobesv (2011-11-02 10:25:41+00:00)
Title: Remove in-memory caches

This patch removes the in-memory caches. It also includes my improvements to support gzip since otherwise the two changes would conflict. Let me know if you'd like a non-gzip-included version of this.

Originally I considered fixing the caching issues I saw, such as:

1. The cache is always populated with the static file result even if caching is disabled
2. Items are never removed from the cache, so this may use a lot of memory
3. In serveDir it checks if (pathname in exports.store) but runs streamFiles(exports.indexStore[pathname].files) (i.e. checking one cache but reading the other)

But I realized that users requiring in-memory caching should do this as part of a smarter middleware component or inside a proxy in front of node rather than leaning on the static files component to deal with it internally.

That way the memory overhead of the cache can be better controlled, monitored, and utilized by all components of the server (or cluster).

The cache as-is will be a kind of liability due to its unbounded size, and creating a full-featured cache might be more appropriate as its own project where dynamically output content within the node server can also benefit from it.

Thanks!

Dobes