title: Firebase persistence, clear Firebase cache
body: <p>My app uses Firebase to sync and restore data. I use the <code>setValue:withCompletionBlock:</code> method to insert, update and delete Firebase objects. This method is called whenever there is a CoreData save, thus syncing all my local changes to Firebase</p>
  
  <pre><code>- (void) setValue:(id)value withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block;
  </code></pre>
  
  <p>Now syncing uploads all the local data to firebase, while restore replaces the local data with firebase data. </p>
  
  <pre><code>- (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block;
  </code></pre>
  
  <p>I observe <code>FEventTypeValue</code> and use the <code>FDataSnapshot</code> to get data from the Firebase and restore the local data.</p>
  
  <p>So everything works perfectly for me until I set <code>persistence</code> to Firebase.</p>
  
  <pre><code>[Firebase setOption:@"persistence" to:@YES];
  </code></pre>
  
  <p>Now when <code>persistence</code> is on, when I update, say insert an object into Firebase, and then restore, the data before the insertion is restored. ie the newly inserted object is not restored. However if I restore again, the inserted object is restored. The same thing happens when an object is deleted. The deleted object reappears when I restore for the first time and vanishes when I restore again. I can see that the Firebase objects are inserted and/or deleted correctly through the Firebase data view.</p>
  
  <p>I'm not sure what I'm doing wrong here. I only have issue when I restore. I think the Firebase cache is causing this restore issue. I'm thinking of clearing the Firebase cache before I restore. My question is</p>
  
  <ol>
  <li>Is clearing the cache before a restore a good method?</li>
  <li>If yes, how to clear the Firebase cache?</li>
  <li>If no, can you suggest me the best method to restore data.</li>
  </ol>