bazaarvoice/dropwizard-webjars-resource — pull request #3 by diroussel (2013-01-13 11:44:59+00:00)
Title: webjars resource caching fix

Fixed a bug where the wrong URL was being constructed to read the resource from the class loader. It's strange that this didn't work for me. I hit this when trying to get ExtJS web jars to work with tomcat embedded. Note: I wasn't using drop wizard, but I wouldn't expect that to affect the path to a resource on the class path.

Along the way I made some other changes:
* updated to latest jersey-server version
* Removed @SuppressWarning("UnusedDeclaration"), you don't need them on a public method
* Set cache limit based on file size
* Allow cache entries to to expire in time. But there is no clean up thread, so this only happens on access. Ideally we'd cache the header (last modified, stag, etc) separately from the bytes content to save space.
* Avoid infinite size of version cache, or attacker could fuzz it into consuming all memory.
* removed "versionCache.put(…)" as entry is already present.

Future improvements:
* Cache bytes separately from headers
* Cache a URL, not bytes. Not that simple, but possible.
* Set latest modified in a way that survives server restart. And is consistent in a cluster. Perhaps parse jar location and use last modified time of jar file, or war file.

You may want to discard the import statements, as I seem to have messed up the order.