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

320
Vistas
Is it possible to cache a XML within a Javascript/HTML, if so how to?

I currently have the following Javascript as part of my HTML

function guide1(i) {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            guideload1(this, i);
        }
    };
    xmlhttp.open("GET", "tvguidedata.xml", true);
    xmlhttp.send();
}

function guideload1(xml, i) {
    var i
    var xmlDoc = xml.responseXML; 
    x = xmlDoc.getElementsByTagName("programme");
    for (i = 1; i <x.length; i++)
                if (*blah blah blah, the script starts working here, I assume its not necessary posting it in full*)

This script works as intended and so far so good. However I would like to improve a small part of it for (what I consider) better performance of the overall intend. Currently I have another script that is calling the above script at an set interval to make sure the data displayed inside my HTML is current (TV Guide airings) Checking the chrome dev tools, I can see each time the script is running it re-downloads the full xml. While the XML file is small, I would prefer it to only load/download the xml once and then be able to loop my script with the data being processed from a cached xml. Is this even possible at all? And if so how? I already tried my setInterval script to directly call the "guideload1" function instead of "guide1, however then I get an error and the script is not loading data correctly. Maybe there is a script that first loads the XML into cache, local storage or whatever would be used in this case and any subsequent calls to "guide1" function and/or "guideload1" then take the cached file and don't make any download requested. And the script that caches the XML, I would most likely set it to only reload/download once after 12 hours.

Any help is appreciated, I should also note that I know almost zero about coding (I got most of my coode by google search and similar) so if an explanation is necessary feel free to phrase it like I'm a baby.

Other information, I believe could be useful: Cross-Browser compatibility is not required/necessary. My whole HTML is only opened on Chrome browswer on Windows in kiosk mode. There is never any user interaction, as the page is displayed to a HDMI-OUT/Modulator and certain sub-HTML elements are reloaded every day at midnight

about 4 years ago · Santiago Trujillo
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