Local Cache to Sync-gateway syncing

We have a hybrid mobile app with PouchDB as the local DB and Sync Gateway to sync with CouchDB. We have a backend where we can enter/delete data as well. I need to know what is the functionality when we set the _exp of a document in syncgateway.
The scenario is as follows.

  1. Log in to the app.
  2. Do some actions which modifies some document(s).
  3. Immediately log out after the action get processed from backend and before all the updated documents gets synced from backend to syncgateway.
  4. Delete the document in backend and set the _exp to 3mins.
  5. Wait until 3 mins pass, check the syncgateway , the document get deletes effecting _exp.
  6. Now there’s no document in syncgateway but it is in local cache.
  7. Login with the same user.
  8. Looking for the document in the app and it still displays data.
  9. Which means even if the document is not in syncgateway, the document in local db is not deleted and this is wrong as per the practical scenario.
    My question is, how can we make this document in local cache get to delete?

Assuming you mean Couchbase Server here right?

Anyway, _exp is based on the ability to purge. Purging is not a replicated action, meaning that it is correct that it does not disappear in your local database. If you want it gone in your local database as well you will have to purge it there as well. PouchDB is not developed here so I don’t know its capabilities but can it set expirations too? Couchbase Lite in 1.x will react to the presence of the _exp property and setup its own local expiration. I don’t know what PouchDB does, if anything. If it doesn’t seem to be working, are you able to pull pull up the _exp data and set an expiration yourself?

At the end of the day PouchDB is not 100% compatible with Sync Gateway. Couchbase has made some moves away from and on top of the CouchDB protocol that PouchDB adheres to. A few months ago they merged a PR to remove all traces of Sync Gateway from their documentation (see here for more info) so take away from that what you will.

Thanks a lot for the response. Yes I meant Couchbase Server.