Choose cache freshness
Board requests are cached by serialized request arguments (URL and request options, including body/headers). Caching is on by default; a typical scraper TTL is one day. Choose freshness for your task: an alerting diff needs a fresh list, while interactive browsing can reuse a short-lived response.
import { clearCache, configureCache, time } from '@chrisdothtml/job-scraper';
configureCache({ ttl: time.hour }); // override every scraper's TTL
configureCache({ enabled: false }); // always hit the network
configureCache({ dir: '/tmp/jobs' }); // put it somewhere else
configureCache({ ttl: undefined }); // drop the override again
await clearCache(); // returns how many entries wentEffective settings
Section titled “Effective settings”CacheConfig contains enabled (true), ttl (null) and dir (default cache location). ttl is milliseconds; null keeps the scraper’s TTL. configureCache merges overrides and undefined removes an override. getCacheConfig returns the effective policy.
Precedence is explicit override → Node environment → default. Node supports:
JOB_SCRAPER_CACHE=offJOB_SCRAPER_CACHE_TTL=3600000Global enabled can turn caching off, but cannot force it back on for a call that opted out, such as a discovery probe. Failed responses are never cached: a 404 body must not be mistaken later for valid posting content.
Clear or relocate responses
Section titled “Clear or relocate responses”clearCache removes cached responses from the configured directory/name and returns the number removed. Registry and search caches have separate clearing APIs. dir is a filesystem location under Node and a Cache API cache name in browsers. Browser responses use the same TTL policy; where the Cache API is unavailable, requests are not cached.
For checking closures, use the still-open recipe and distinguish missing jobs from failed requests.