# with_cache

> **Function** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/utils/with_cache)

Use a cache for requests.

## Signature

```python
with_cache(
    path: Union[str, pathlib.Path],
    ignore_hosts: Optional[Sequence[str]] = None,
    allow_hosts: Optional[Sequence[str]] = None,
) -> Generator[None, None, None]
```

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/51bff1a3a85a9f692346697c4dda5ec9fa12b947/python/langsmith/utils.py#L580)