Skip to content

Commit 68415d7

Browse files
committed
Add HTTP cache check
1 parent dca6f20 commit 68415d7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

js/obs.speedcurve.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,18 @@
3434
window.LUX.addData(key, obs[key]);
3535
}
3636
}
37+
38+
// Was the response from HTTP cache or the network?
39+
const navigation = performance.getEntriesByType('navigation')[0];
40+
41+
if (!navigation) return;
42+
43+
const { encodedBodySize } = navigation;
44+
45+
if (encodedBodySize === 0) {
46+
LUX.addData('fromCache', true);
47+
} else if (encodedBodySize > 0) {
48+
LUX.addData('fromCache', false);
49+
}
50+
3751
})();

0 commit comments

Comments
 (0)