Advertisement
Guest User

Untitled

a guest
Dec 19th, 2011
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. === index.html ===
  2.  
  3. <!doctype html>
  4. <html manifest="test.appcache">
  5. <head>
  6. <meta charset="utf-8">
  7. <title>Connectivity Test</title>
  8. <script src="script.js"></script>
  9. </head>
  10.  
  11. <body>
  12. <h1>Let's test this connection!</h1>
  13. <button onclick="go()">Do it!</button>
  14. </body>
  15. </html>
  16.  
  17. === script.js ===
  18.  
  19. function testOnline(fn) {
  20. var script = document.createElement('script');
  21. script.src = 'online.js';
  22.  
  23. window.setOnline = function(online) {
  24. document.body.removeChild(script);
  25. fn(online);
  26. }
  27.  
  28. document.body.appendChild(script);
  29. }
  30.  
  31. connectivity = function(online) {
  32. online ? alert("Online") : alert("Offline");
  33. }
  34.  
  35. function go() {
  36. testOnline(connectivity);
  37. }
  38.  
  39. === online.js ===
  40.  
  41. setOnline(true);
  42.  
  43. === offline.js ===
  44.  
  45. setOnline(false);
  46.  
  47. === test.appcache ===
  48.  
  49. CACHE MANIFEST
  50.  
  51. # Version: 1
  52.  
  53. CACHE:
  54. index.html
  55. script.js
  56.  
  57. NETWORK:
  58. *
  59.  
  60. FALLBACK:
  61. online.js offline.js
  62.  
  63. === .htaccess ===
  64.  
  65. AddType text/cache-manifest .appcache
  66.  
  67. <IfModule mod_expires.c>
  68. ExpiresActive on
  69. ExpiresDefault "access plus 1 month"
  70.  
  71. ExpiresByType text/cache-manifest "access plus 0 seconds"
  72. ExpiresByType text/html "access plus 0 seconds"
  73. ExpiresByType application/json "access plus 0 seconds"
  74. ExpiresByType text/css "access plus 0 seconds"
  75. ExpiresByType application/javascript "access plus 0 seconds"
  76.  
  77. <IfModule mod_headers.c>
  78. Header append Cache-Control "public"
  79. </IfModule>
  80.  
  81. </IfModule>
  82.  
  83. <IfModule mod_headers.c>
  84. Header unset ETag
  85. </IfModule>
  86.  
  87. FileETag None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement