Add file caching

Closes #28.