Hey. In order for the user to see the beautiful preloader download site, I use the following code:

var xhr = new XMLHttpRequest(); //path -- это переменная с адресом файла на сервере. Список path так же получаю с сервера. //задаю переменную path в xhr, для доступа из событий onload, error, ... xhr.path = path.toString(); xhr.open("GET", 'https://web.lotus-app.ru/' + path, true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.responseType = "blob"; //задаю onload, progress, abort, errror, timeout xhr.send(); 

All files (js, svg, css, tff, html) from the site are loaded, but when they are needed by the browser, they are loaded again, i.e. This whole preload does not give anything. How to do it right?

Addition

Found that the files that the browser needs are of type: stylesheet, png, svg + xml, script, document; and those that I ship: xhr ...

type

  • Look at the Service Worker . they are not yet supported everywhere, but they do what you need. - Mikhail Vaysman
  • @MikhailVaysman "Not Everywhere" - How Much? _) Ps Ah, that's it, I see ... - Sviatoslav Zaytsev
  • follow the link and see - Mikhail Vaysman

1 answer 1

Caching is disabled in your browser console - in this case, requests will always go to the server.

  • Damn, I blunted. Thank you, bro!) - Sviatoslav Zaytsev