项目作者: afeiship

项目描述 :
You need to instead of this file to server url.
高级语言: JavaScript
项目地址: git://github.com/afeiship/fallback.js.git
创建时间: 2019-05-17T06:48:32Z
项目社区:https://github.com/afeiship/fallback.js

开源协议:MIT License

下载


fallback.js

You need to instead of this file to server url

description

  1. Add this file to your app index.html
  2. Use http link.
  3. Just an empty file.
  4. If your want to force to clean users cache and something quick things, you can use this file.

usage

  1. Download fallback.js
    1. curl https://cdn.jsdelivr.net/gh/afeiship/fallback.js/index.js > fallback.js
  2. Add to your own project file
    1. <!--DO NOT DELETE THIS FILE-->
    2. <script src="//tsscdn.finxos.com/cloud/statics/fallback.js"></script>
    3. <!--DO NOT DELETE THIS FILE-->

inline solution

  1. window.onload = function() {
  2. var head = document.getElementsByTagName('head')[0];
  3. var fbScript = document.createElement('script');
  4. fbScript.type = 'text/javascript';
  5. fbScript.async = true;
  6. // this url MUST NOT BE cached by sw.js
  7. fbScript.src = './fallback.js?v=' + Date.now();
  8. fbScript.onload = function() {
  9. if (navigator && navigator.serviceWorker && window.__SW_DISABLED__) {
  10. console.log('[ 😂Cache has clean! ]');
  11. navigator.serviceWorker.getRegistration('/').then(function(reg) {
  12. reg && reg.unregister();
  13. });
  14. }
  15. };
  16. head.appendChild(fbScript);
  17. };