backport of cache changes from 0.6
Merge pull request #158 from andrewmcguinness/0.5.x-cache

backport of cache changes from 0.6