> For the complete documentation index, see [llms.txt](https://henryruhs.gitbook.io/ngx-crud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://henryruhs.gitbook.io/ngx-crud/api/http-caching.md).

# HTTP Caching

### Switch

Enable caching for the service:

```typescript
crudService.enableCache(method : UniversalMethod = 'GET', lifetime : number = 2000) : this
```

Disable caching for the service:

```typescript
crudService.disableCache() : this
```

### Flush

Flush all caches of the service:

```typescript
crudService.flush() : this
```

Flush a single cache by its `urlWithParams` for enabled services:

```typescript
cacheService.flush(urlWithParams : string) : this
```

Flush many caches by their `url` for enabled services:

```typescript
cacheService.flushMany(url : string) : this
```

Flush all caches for enabled services:

```typescript
cacheService.flushAll() : this
```

### Observe

Observe a single cache by its `urlWithParams` for enabled services:

```typescript
cacheService.observe(urlWithParams : string) : Observable<[string, Store]>
```

Observe many caches by their `url` for enabled services:

```typescript
cacheService.observeMany(url : string) : Observable<[string, Store]>
```

Observe all caches for enabled services:

```typescript
cacheService.observeAll() : Observable<[string, Store]>
```
