protocol

HTTP Cache

HTTP caching stores copies of responses at the client or an intermediate proxy, allowing subsequent requests for the same resource to be served without a full server round-trip.

HTTP defines a rich set of caching headers that control how responses are stored and reused. `Cache-Control: max-age=3600` tells clients to use a cached copy for up to one hour. `ETag` and `Last-Modified` headers enable conditional requests: the client sends `If-None-Match` or `If-Modified-Since` headers, and the server responds with 304 Not Modified (no body, just reconfirm the cache is valid) if the content has not changed.

For scrapers, HTTP caching is a double-edged tool. On one hand, respecting cache headers reduces unnecessary requests to the target server (polite and efficient). On the other hand, scraping platforms should validate cache freshness before returning cached data, especially for price monitoring or news aggregation where staleness matters.

Some anti-bot systems manipulate cache headers to force scrapers to make more requests (disabling caching) or to detect scrapers that ignore cache control (never requesting fresh content). Understanding cache semantics helps scrapers behave like real browsers.

Examples

# Check if response is fresh or from cache
import requests

response = requests.get("https://example.com/prices")
cache_control = response.headers.get("Cache-Control", "")
age = response.headers.get("Age", "0")  # seconds since cached
etag = response.headers.get("ETag")
print(f"Cache-Control: {cache_control}, Age: {age}s, ETag: {etag}")

Related Terms

Extract HTTP Cache data from any website

AlterLab returns clean, structured data from any public URL — no scraper infrastructure needed. Start free, no credit card required.

View API docs

Your first scrape.
Sixty seconds.

$1 free balance. No credit card. No SDK.Just a POST request.

terminal
curl -X POST https://api.alterlab.io/v1/scrape \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "formats": ["markdown"]}'

No credit card required · Up to 5,000 free scrapes · Balance never expires

    HTTP Cache — Web Scraping Glossary | AlterLab