So it’s been a long time since I started working on AIRi package and now it’s time to start addressing performance issues. One of the problems was that I noticed it wasn’t using the browser cache at all!

By researching I noticed the problem was actually my PkgFile class which was dumping content from the egg file using pkg_resources.resource_stream…. Which in fact isn’t the most efficient way, as pkg_resources actually uncompress the hole egg file (or just uses a folder if accessible).

So the way to serve static content from either egg files or folder with pkg_resources in Twisted is REALLY simple, here’s an example: