Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72416

How to setup "connect-cache-manifest" for node/express app

$
0
0

I am trying to cache a html page with all js, css and images needed.

Its is located in the public folder of an nodejs/express app.

So far i installed de npm "connect-cache-manifest" found here https://www.npmjs.com/package/connect-cache-manifest

This is the require

const cacheManifest = require('connect-cache-manifest');

And this should generate the manifest i need:

app.use(cacheManifest({
    manifestPath: '/application.manifest',
    files: [{
      file: __dirname + '/public/js/jquery.min.js',
      path: '/js/jquery.min.js'
    }, {
      dir: __dirname + '/public/js/bootstrap.min.js',
      path: '/js/bootstrap.min.js'
    }, {
      dir: __dirname + '/public/js/bootbox.min.js',
      path: '/js/bootbox.min.js'
    }, {
        dir: __dirname + '/public/js/moment.js',
        path: '/js/moment.js'
      }, {
        dir: __dirname + '/public/js/jquery.mask.js',
        path: '/js/jquery.mask.js'
      }, {
        dir: __dirname + '/public/js/datatables.js',
        path: '/js/datatables.js'
      }, {
        dir: __dirname + '/public/css/bootstrap.min.css',
        path: '/css/bootstrap.min.css'
      }, {
        dir: __dirname + '/public/css/datatables.css',
        path: '/css/datatables.css'
      }, {
        dir: __dirname + '/public/offline.html',
        path: '/offline'
      }],
    networks: ['*'],
    fallbacks: []
  }));

I access the page with internet conection and it is displayed normaly, if i keep the browser open and turn on flight mode, i can use the page without problems.

Once i close de browser (Chrome) and access teh page again i get Chromes Dinosaur teling me no page due to no internet conection.

i added this line to the html page to be cached

<html lang="es-CL" manifest="/application.manifest">

What am i missing.

Does it requiere an actual file "application.manifest"? if so where should it be placed (public folder)?

Thanks for helping


Viewing all articles
Browse latest Browse all 72416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>