Created
February 1, 2019 18:35
-
-
Save jonchenn/255278f60a9f2fa8da9335061ca1a010 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = await idbKeyval.get(id, store); | |
if (!data) return null; | |
// Check cache max age. | |
let cacheControl = request.headers.get('Cache-Control'); | |
let maxAge = cacheControl ? parseInt(cacheControl.split('=')[1]) : 3600; | |
if (Date.now() - data.timestamp > maxAge * 1000) { | |
return null; // Invalidate the cache data. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment