Make caching more general