Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === index.html ===
- <!doctype html>
- <html manifest="test.appcache">
- <head>
- <meta charset="utf-8">
- <title>Connectivity Test</title>
- <script src="script.js"></script>
- </head>
- <body>
- <h1>Let's test this connection!</h1>
- <button onclick="go()">Do it!</button>
- </body>
- </html>
- === script.js ===
- function testOnline(fn) {
- var script = document.createElement('script');
- script.src = 'online.js';
- window.setOnline = function(online) {
- document.body.removeChild(script);
- fn(online);
- }
- document.body.appendChild(script);
- }
- connectivity = function(online) {
- online ? alert("Online") : alert("Offline");
- }
- function go() {
- testOnline(connectivity);
- }
- === online.js ===
- setOnline(true);
- === offline.js ===
- setOnline(false);
- === test.appcache ===
- CACHE MANIFEST
- # Version: 1
- CACHE:
- index.html
- script.js
- NETWORK:
- *
- FALLBACK:
- online.js offline.js
- === .htaccess ===
- AddType text/cache-manifest .appcache
- <IfModule mod_expires.c>
- ExpiresActive on
- ExpiresDefault "access plus 1 month"
- ExpiresByType text/cache-manifest "access plus 0 seconds"
- ExpiresByType text/html "access plus 0 seconds"
- ExpiresByType application/json "access plus 0 seconds"
- ExpiresByType text/css "access plus 0 seconds"
- ExpiresByType application/javascript "access plus 0 seconds"
- <IfModule mod_headers.c>
- Header append Cache-Control "public"
- </IfModule>
- </IfModule>
- <IfModule mod_headers.c>
- Header unset ETag
- </IfModule>
- FileETag None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement