# persistence

Redux-rest-easy works out-of-the-box with libraries such as [redux-offline](https://github.com/redux-offline/redux-offline) and [redux-persist](https://github.com/rt2zz/redux-persist). However, the library will need to clean the state before persisting it, so that it never ends up in an inconsistent shape.

Here is a list of actions performed when you call [getPersistableState](/redux-rest-easy/docs/api/getpersistablestate.md):

* In-progress requests are deleted. *This is to avoid pending requests never resolving.*
* Expired and invalidated requests are deleted. *This is to avoid keeping outdated requests possibly forever.*
* Requests with `expireAt` set to `never` (`cacheLifetime` set to `Infinity`) are invalidated. *This is to avoid trusting remote data forever. Can still be done via persistOptions.alwaysPersist*
* Resources which are no longer referenced by any request are deleted. *This is to avoidkeeping outdated resources in the state.*
* resolversHashes which refer to no longer existing requests or modified resources are deleted. *This is to avoidkeeping outdated hashes in the state.*

The first action is mandatory to avoid inconsistent state, but the others won't be applied to requests performing on resources defined in `persistOptions.alwaysPersist` and `persistOptions.neverPersist`. Instead, such requests will always/never be persisted.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brigad.gitbook.io/redux-rest-easy/docs/principles/persistence.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
