Add cache for faster loading. This cache uses a weak hash map to avoid
consuming too much memory.