caching and encoding