Cached Results

ScraperAPI's caching system unlocks a new level of efficiency. By leveraging advanced decision-making mechanisms, we maintain an extensive amount of cached data, that is ready to be served if called upon. When you request a page with a cached response available, you'll receive the cached data, ensuring much faster access to the information you need with a 100% success rate.

Why is this good?

  • Difficult Pages: Perfect for pages that are challenging to scrape.

  • 10-Minute Updates: No older than 10 minutes cached value.

  • Guaranteed Success: 100% success rate for cached results.

  • Faster Response Times: Retrieve data quicker from cached results.

  • Fewer Retries: Reduced number of retries needed to serve back the response.

This feature applies only to requests that include the ultra_premium=true parameter and is enabled by default.

What's in it for you?

  • 🚀Increased Efficiency: Save time and resources by reducing the need to scrape the same page multiple times.

  • Improved Reliability: Enhance the reliability of your scraping tasks with consistent and timely data retrieval.

Advanced Use-Case Scenario

For cases where real-time data is required, you can ensure the API serves uncached data by adding the parameter cache_control=no-cache to the URL, as shown below:

try {
String apiKey = "APIKEY";
String url = "https://api.scraperapi.com/?api_key=" + apiKey + "&ultra_premium=true&cache_control=no-cache&url=http://httpbin.org/ip";
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
conection.setRequestMethod("GET");
int responseCode = conection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(conection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}

We tag cached responses with the sa-from-cache: 1 response header, making it easy to distinguish between cached and non-cached responses.

Future Enhancements

We're always looking to improve. Stay tuned for the upcoming max_age option, which will give you even more control over your caching preferences.

Last updated