Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

662
Visualizações
Adjust Firestore cache size with AngularFire

I'm trying to figure out the best way to enable Firestore persistence and adjust the cache size using AngularFire.

Firebase documentation suggest we do it like this:

firebase.firestore().settings({
     cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED
});

AngularFire does not mention adjusting such settings, but digging into the code it looks like you can pass an object of type "firebase.firestore.PersistanceSettings" in as such:

AngularFirestoreModule.enablePersistence({
      experimentalForceOwningTab: true,
      synchronizeTabs: true,
}),

However, those are the only two properties allowed in the PersistanceSettings type.

I tried creating a constructor in app.module.ts and doing things according to the Firebase documentation but I'm not even sure if it is working.

export class AppModule {
  constructor() {
    firebase.firestore().settings({
      cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED,
    });
  }
}

How do I check what the cache size settings are at run time? Am I doing it right?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

CACHE_SIZE_UNLIMITED is -1, to be set preferably in app.module.ts:

const settings: firebase.firestore.Settings = {
  cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED
};
firebase.firestore().settings(settings);

There doesn't seem to be a method to read the settings... cacheSizeBytes is already known.
And one probably cannot change the value of cacheSizeBytes either, once having connected.

over 4 years ago · Santiago Trujillo Relatório

0

Searching around the AngularFire documentation, I found their document related to offline storage. It explains how to enable file persistence in your app and also that you can test whether a document is retrieved from cache or Firestore using the fromCache property.

To check whether you are receiving data from the server or the cache, use the fromCache property on the SnapshotMetadata in your snapshot event. If fromCache is true, the data came from the cache and might be stale or incomplete. If fromCache is false, the data is complete and current with the latest updates on the server.

As for setting the cache size for Firestore, it appears that the only way is what you have been trying and it is a variable set in the Firestore instance properties. Here are full samples from the documentation related to setting the cache size and enabling persistence.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda