Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

660
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda