@@ -90,6 +90,50 @@ function filtersToJsObjectString(filters: any[], indent: number = defaultIndenta
9090 const formattedString = `{\n` + entries . join ( '\n' ) + `\n${ bracketsIndentationStr } }`
9191 return formattedString
9292}
93+
94+ function createCachingText ( enable_cache : boolean ) : string {
95+ if ( enable_cache ) {
96+ return `## Caching
97+
98+ The API automatically **caches** results to minimize redundant scraping. This means:
99+ - Scraper results are stored based on input data
100+ - Subsequent requests with the same input data return cached data instantly
101+
102+ ### Changing Cache Settings
103+
104+ You can change this caching behavior when initializing the API client:
105+
106+ \`\`\`typescript
107+ // Option 1: Disable caching for fresh results
108+ const api = new Api({ enableCache: false })
109+
110+ // Option 2: Keep caching enabled (default)
111+ const api = new Api({ enableCache: true })
112+ \`\`\`` ;
113+ } else {
114+ return `## Caching
115+
116+ The API does not **cache results**, so you get fresh results on every request.
117+
118+ ### Changing Cache Settings
119+
120+ You can change this caching behavior when initializing the API client:
121+
122+ \`\`\`typescript
123+ // Option 1: Enable caching to improve performance
124+ const api = new Api({ enableCache: true })
125+
126+ // Option 2: Keep caching disabled for fresh results (default)
127+ const api = new Api({ enableCache: false })
128+ \`\`\`
129+
130+ When caching is enabled:
131+ - Scraper results are stored based on input data
132+ - Subsequent requests with the same input data return cached data instantly` ;
133+ }
134+
135+ }
136+
93137function createApiTaskText ( scraperName : string , hasSingleScraper : boolean , defaultData : any , maxRunsMessage ) : string {
94138 const x = hasSingleScraper ? '' : `scraperName: '${ scraperName } ', `
95139
@@ -418,7 +462,7 @@ This will:
418462- Make a **GET** request to the \`${ final [ 0 ] } \` endpoint.
419463- Execute the scraper immediately, bypassing task creation, scheduling, and running overhead.
420464- Validate input data before execution, returning a \`400\` error for invalid requests.
421- ${ enable_cache ? '- Cache the results based on the provided parameters .\n' : '' } - ${ maxRunsMessage2 }
465+ ${ enable_cache ? '- Cache the results based on the provided input data .\n' : '' } - ${ maxRunsMessage2 }
422466
423467This method is especially useful when:
424468
@@ -482,6 +526,8 @@ async function main() {
482526main()
483527\`\`\`
484528
529+ ${ createCachingText ( enable_cache ) }
530+
485531## That's It!
486532
487533Now, go and build something awesome.`
0 commit comments