]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/examples/pwa/sw-precache.js
Add Progressive Web App examples and docs
[working/Evergreen.git] / Open-ILS / examples / pwa / sw-precache.js
1 module.exports = {
2   staticFileGlobs: [
3     '/openils/var/web/favicon.ico',
4     '/openils/var/web/offline.html',
5     '/openils/var/web/js/sw-register.js',
6     '/openils/var/web/css/skin/default/opac/semiauto.css',
7     '/openils/var/web/js/ui/default/opac/simple.js',
8     '/openils/var/web/opac/images/small_logo.png',
9     '/openils/var/web/opac/images/progressbar_green.png',
10     '/openils/var/web/opac/images/main_logo.png',
11     '/openils/var/web/opac/images/eg_tiny_logo.png'
12   ],
13   stripPrefix: '/openils/var/web/',
14   runtimeCaching: [
15     // aggressively cache images
16     {
17       urlPattern: /\.(gif|jpg|jpeg|png)$/,
18       handler: 'fastest'
19     },
20     // aggressively cache stylesheets and JavaScript
21     {
22       urlPattern: /\.(css|js)$/,
23       handler: 'fastest'
24     },
25     // cache added content too
26     {
27       urlPattern: /\/opac\/extras\/ac\//,
28       handler: 'fastest'
29     },
30     // results can take a long time to respond
31     {
32       urlPattern: /\/eg\/opac\/results\//,
33       handler: 'networkFirst',
34       options: {
35         networkTimeoutSeconds: 60
36       }
37     },
38     // prefer the network, but fall back to the cache
39     {
40       urlPattern: /\/(eg|js|opac|staff)\//,
41       handler: 'networkFirst',
42       options: {
43         networkTimeoutSeconds: 4
44       }
45     }
46   ]
47 };