-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
53 lines (47 loc) · 1.08 KB
/
index.html
File metadata and controls
53 lines (47 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello from SashiDo :)</title>
<style>
html,
body {
margin: 0;
font-size: 16px;
line-height: 1;
color: #c7c8ca;
font-weight: 300;
background: #1e2228;
font-family: sans-serif;
}
#content {
width: 100vw;
height: 100vh;
padding: 20px;
}
</style>
</head>
<body>
<div id="content">
<button id="button" onclick="clickButton()">Try Cached Fetch</button>
<pre id="pre"></pre>
</div>
<script type="text/javascript">
if ('serviceWorker' in navigator && 'caches' in window) {
navigator.serviceWorker.register('//pivanov.github.io/fetch-cache/sw.js');
}
const clickButton = () => {
fetch(
'//pivanov.github.io/fetch-cache/db.json', {
headers: {
"SW-Cache-For-Seconds": 5
},
})
.then(r => r.json())
.then(data => {
document.getElementById('pre').innerHTML = JSON.stringify(data, null, 2);
});
}
</script>
</body>
</html>