offline-handler
Version:
Allow your users to use your website while offline easily
134 lines (92 loc) • 3.95 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><h1>OfflineHandler <a href="https://zenoo.github.io/offline-app-example/">(Demo)</a></h1><p>Allow your users to use your website while offline easily</p>
<h3>Doc</h3><ul>
<li><strong>Installation</strong></li>
</ul>
<p>Simply import <code>OfflineHandler.min.js</code> into your HTML <strong>and</strong> download <a href="https://raw.githubusercontent.com/Zenoo/offline-handler/master/OfflineHandler-sw.min.js" target="_blank"><code>OfflineHandler-sw.min.js</code></a> <strong>at the root of your project</strong>.</p>
<pre class="prettyprint source"><code><script src="https://gitcdn.link/repo/Zenoo/offline-handler/master/OfflineHandler.min.js"></script> </code></pre><ul>
<li><p><strong>How to use</strong></p>
<ul>
<li><p>Create a new <a href="https://zenoo.github.io/offline-handler/OfflineHandler.html"><code>OfflineHandler</code></a> object with the ressources to be cached as the first parameter :</p>
<pre class="prettyprint source"><code>let ajax = new OfflineHandler(['path/to/customFile.js'], ...);</code></pre></li>
<li><p>Call your URLs with an additional parameter : <code>?v=1</code>, or without any to get the default version.<br>Changing this parameter will create a new cache version.<br>Calling your URLs with <code>?v=no-cache</code> will bypass the cached versions</p>
</li>
</ul>
</li>
<li><p><strong>Parameters</strong></p>
</li>
</ul>
<pre class="prettyprint source"><code> /**
* List of ressources to be cached
* The current page is always cached, no need to add it here
* @type {String[]}
*/
const ressourceList = [
'path/to/customFile.js',
'pathto/the/customCss.css'
];
/**
* /|\ OPTIONAL /|\
* Path to the OfflineHandler ServiceWorker file
* @type {String}
* @default OfflineHandler-sw.min.js
*/
const serviceWorkerPath = 'OfflineHandler-sw.min.js';
/**
* /|\ OPTIONAL /|\
* Name of the URL parameter that holds the version of the files
* @type {String}
* @default v
*/
const versionParameter = 'v';
/**
* /|\ OPTIONAL /|\
* Should the old cached versions be deleted when a new one is created ?
* @type {Boolean}
* @default false
*/
const clearOldCache = false;
/**
* /|\ OPTIONAL /|\
* Should external requests be cached ?
* @type {Boolean}
* @default false
*/
const cacheExternalRequests = false;
new OfflineHandler(ressourceList, serviceWorkerPath, versionParameter, clearOldCache, cacheExternalRequests);</code></pre><ul>
<li><strong>Example</strong></li>
</ul>
<p>See this <a href="https://github.com/Zenoo/offline-app-example">Github project</a> for a working example.</p>
<h2>Authors</h2><ul>
<li><strong>Zenoo</strong> - <em>Initial work</em> - <a href="https://zenoo.fr">Zenoo.fr</a></li>
</ul></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="OfflineHandler.html">OfflineHandler</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Dec 21 2018 09:29:06 GMT+0100 (Romance Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>