rewrite when should_cache