feat: do not revalidate every first load
This commit is contained in:
parent
cf065e3901
commit
2d0c74fc1e
1 changed files with 8 additions and 10 deletions
|
@ -63,16 +63,14 @@ export interface Props {
|
||||||
|
|
||||||
let responseText;
|
let responseText;
|
||||||
|
|
||||||
const fullResponse = await cache.match(url)
|
/**
|
||||||
|
* TODO: determine when & how to revalidate
|
||||||
|
*/
|
||||||
|
|
||||||
try {
|
const fullResponse = await cache.match(url)
|
||||||
const responseFromNetwork = await fetch(url, {method: 'GET'});
|
if (!fullResponse && url.slice(0, url.length - 1) !== baseUrl && !skipSave && !includesAppURL) {
|
||||||
if (responseFromNetwork && url.slice(0, url.length - 1) !== baseUrl && !skipSave && !includesAppURL) {
|
|
||||||
logInfo('updating cached', {context: 'cozy-reader', data: url})
|
logInfo('updating cached', {context: 'cozy-reader', data: url})
|
||||||
await cache.put(url, responseFromNetwork);
|
await cache.add(url);
|
||||||
}
|
|
||||||
} catch(error) {
|
|
||||||
logError('failed to update cached', {context: 'cozy-reader', data: {url, error}})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fullResponse?.text().then(async data => {
|
fullResponse?.text().then(async data => {
|
||||||
|
|
Loading…
Reference in a new issue