Nick: from cache fixes
This commit is contained in:
@@ -10,6 +10,9 @@ export async function scrapeCache(meta: Meta): Promise<EngineScrapeResult> {
|
|||||||
const entry = await getEntryFromCache(key);
|
const entry = await getEntryFromCache(key);
|
||||||
if (entry === null) throw new EngineError("Cache missed");
|
if (entry === null) throw new EngineError("Cache missed");
|
||||||
|
|
||||||
|
// Set fromCache flag to indicate this document was retrieved from cache
|
||||||
|
meta.internalOptions.fromCache = true;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: entry.url,
|
url: entry.url,
|
||||||
html: entry.html,
|
html: entry.html,
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ export type InternalOptions = {
|
|||||||
useCache?: boolean;
|
useCache?: boolean;
|
||||||
disableSmartWaitCache?: boolean; // Passed along to fire-engine
|
disableSmartWaitCache?: boolean; // Passed along to fire-engine
|
||||||
isBackgroundIndex?: boolean;
|
isBackgroundIndex?: boolean;
|
||||||
|
fromCache?: boolean; // Indicates if the document was retrieved from cache
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EngineResultsTracker = {
|
export type EngineResultsTracker = {
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ export function saveToCache(meta: Meta, document: Document): Document {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the document was retrieved from cache, we don't need to save it
|
||||||
|
if (meta.internalOptions.fromCache) {
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const key = cacheKey(meta.url, meta.options, meta.internalOptions);
|
const key = cacheKey(meta.url, meta.options, meta.internalOptions);
|
||||||
|
|
||||||
if (key !== null) {
|
if (key !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user