Spaces:
Build error
Build error
fix: cache with locale
Browse files
backend/functions/src/cloud-functions/crawler.ts
CHANGED
|
@@ -100,6 +100,9 @@ export class CrawlerHost extends RPCHost {
|
|
| 100 |
// Potential privacy issue, dont cache if cookies are used
|
| 101 |
return;
|
| 102 |
}
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
await this.setToCache(options.url, snapshot);
|
| 105 |
});
|
|
@@ -1025,7 +1028,10 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
|
|
| 1025 |
cache = await this.queryCache(urlToCrawl, cacheTolerance);
|
| 1026 |
}
|
| 1027 |
|
| 1028 |
-
if (cache?.isFresh &&
|
|
|
|
|
|
|
|
|
|
| 1029 |
yield this.jsdomControl.narrowSnapshot(cache.snapshot, crawlOpts);
|
| 1030 |
|
| 1031 |
return;
|
|
|
|
| 100 |
// Potential privacy issue, dont cache if cookies are used
|
| 101 |
return;
|
| 102 |
}
|
| 103 |
+
if (options.locale) {
|
| 104 |
+
Reflect.set(snapshot, 'locale', options.locale);
|
| 105 |
+
}
|
| 106 |
|
| 107 |
await this.setToCache(options.url, snapshot);
|
| 108 |
});
|
|
|
|
| 1028 |
cache = await this.queryCache(urlToCrawl, cacheTolerance);
|
| 1029 |
}
|
| 1030 |
|
| 1031 |
+
if (cache?.isFresh &&
|
| 1032 |
+
(!crawlOpts?.favorScreenshot || (crawlOpts?.favorScreenshot && (cache.screenshotAvailable && cache.pageshotAvailable))) &&
|
| 1033 |
+
(_.get(cache.snapshot, 'locale') === crawlOpts?.locale)
|
| 1034 |
+
) {
|
| 1035 |
yield this.jsdomControl.narrowSnapshot(cache.snapshot, crawlOpts);
|
| 1036 |
|
| 1037 |
return;
|