mirror of
https://github.com/hanzoai/workbox.git
synced 2026-09-24 17:04:35 +00:00
* Deps and config * Prettier output * Update hardcoded file sizes * More file size updates
41 lines
1.0 KiB
HTML
41 lines
1.0 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
</head>
|
|
<body>
|
|
<p>Log time of isURLExpired();</p>
|
|
|
|
<script>
|
|
// Fakery to make it load in the window
|
|
self.registration = {
|
|
scope: 'inject-scope',
|
|
};
|
|
</script>
|
|
|
|
<script src="../../../../packages/workbox-core/build/browser/workbox-core.dev.js"></script>
|
|
<script src="../../../../packages/workbox-expiration/build/browser/workbox-expiration.dev.js"></script>
|
|
<script>
|
|
const CacheExpiration = workbox.expiration.CacheExpiration;
|
|
|
|
const expirationManager = new CacheExpiration('cache-name', {
|
|
maxAgeSeconds: 2,
|
|
});
|
|
expirationManager.updateTimestamp('/', Date.now());
|
|
|
|
const test = async () => {
|
|
const t0 = performance.now();
|
|
const expired = await expirationManager.isURLExpired('/');
|
|
const t1 = performance.now();
|
|
console.log(
|
|
`Call to doSomething took "${t1 - t0}" milliseconds.`,
|
|
expired,
|
|
);
|
|
};
|
|
|
|
test();
|
|
|
|
setTimeout(test, 2000);
|
|
</script>
|
|
</body>
|
|
</html>
|