Closed geoffrich closed 1 year ago
Name | Link |
---|---|
Latest commit | 00909586ba7a4d2daf6e03bb4d9d10a06bb47720 |
Latest deploy log | https://app.netlify.com/sites/marvel-by-year/deploys/6353321ae7f55800080b680f |
Deploy Preview | https://deploy-preview-10--marvel-by-year.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Closes #9
Instead of expiring data after 24 hours and refreshing, keep the stale data and refresh it in the background. This works by setting a parallel Redis key at
year:[year]:[page]:c:fresh
that does expire after 24 hours. When retrieving the cached data, we check if that key exists - if it doesn't, then we need to refresh the data, but still return the old data.To refresh the data, we trigger a separate HTTP request against the app. This is because I don't trust the promise to resolve on its own if we already return from the function. We can't use the
fetch
passed to the handler since that will resolve against the app without an HTTP request, and we want to make a separate request.Marvel data doesn't change that much, so the amount of stale data should be negligible. This will be a big perf improvement due to how slow the Marvel API can be.