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

116
Vistas
How to leverage Back-Forward Cache on popstate() event/fetch

Simple progressive enhancement, no framework, etc:

/**
enhance clicks on .xhr elements:
*/
window.addEventListener('click', function(e){
  var t = e.target;
  if(t.closest('.xhr') || t.classList.contains('xhr')){
    fetch(
      t.href, 
      {}
    ).then(function(response){
      // ..
    }).then(function(json){
      window.history.pushState(
        [],
        '',
        t.href
      );
      // change markup on the page, etc..
    });
  }
}, false);

/**
listen to back
*/
window.addEventListener('popstate', function(e) {
  // how to leverage BF-cache here?
  // can it be done?
});

The comment under popstate says it all: is there a way to let the browser automatically use its BF-cache on the popstate event?

about 4 years ago · Juan Pablo Isaza
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