# Http Cache Headers Checker (`eichan/http-cache-headers-checker`) Actor

- **URL**: https://apify.com/eichan/http-cache-headers-checker.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.01 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## HTTP Cache Headers Checker

**One job:** Fetch **response headers only** for a single public HTTP(S) URL and explain what caching instructions the headers declare. The Actor opens one GET request and closes the response without reading its body.

### Who is it for?

Web developers, performance engineers, QA testers, and site owners investigating `Cache-Control` policy for a publicly accessible URL.

### Input

```json
{"url":"https://httpbin.org/cache/60"}
```

`url` must be one full public HTTP or HTTPS URL. The prefilled example is a real httpbin endpoint documented to send `Cache-Control` for 60 seconds. The URL has been checked for a nonempty successful HTTP response using public web retrieval; HTTP header details cannot be independently measured from this build environment because outbound DNS is unavailable.

### Output

Always **one** dataset item. Example of a response with `Cache-Control: public, max-age=3600` (illustrative):

```json
{
  "url": "https://example.org/static/file.css",
  "httpStatus": 200,
  "cacheControl": "public, max-age=3600",
  "maxAgeSeconds": 3600,
  "directives": ["public", "max-age=3600"],
  "expires": null,
  "etagPresent": true,
  "lastModified": "Wed, 21 Oct 2015 07:28:00 GMT",
  "ageSeconds": 30,
  "verdict": "This response declares a cache freshness lifetime of 3600 seconds; actual cache eligibility depends on other HTTP conditions.",
  "status": "ok",
  "error": null
}
```

`cacheControl`, `expires`, and `lastModified` preserve response header **values** without normalization. When repeated `Cache-Control` headers occur, their values are joined in order with `, `, following the combined Cache-Control field format. `directives` preserves directive tokens, including arguments. `maxAgeSeconds` and `ageSeconds` are nonnegative integer values, or `null` when absent/invalid. `maxAgeSeconds` always reports the `max-age` value. When `s-maxage` is also present, the verdict sentence reports the `s-maxage` value as the shared-cache lifetime, because shared caches follow `s-maxage` instead of `max-age`; the two numbers can therefore differ, and both are correct for their audience. `etagPresent` is presence only, not the ETag value. `status` is `ok`, `redirect`, `http_error`, or `error`; `error` is always user-readable.

`verdict` is a **single sentence** derived only from observed headers. It does not guarantee that a response will actually be stored: intermediaries, Vary, authorization, cookies, status code and other conditions can affect cache behavior. `no-store` takes precedence over lifetimes; `no-cache` means stored responses need revalidation, not that storage itself is forbidden. `private` disallows shared-cache storage.

### How to run

Apify input is read from the default key-value store INPUT record via the Apify REST API using only the platform-provided runtime token; results are written to the default dataset via Apify REST. No credentials or third-party SDK are requested from the buyer.

Local run from this Actor folder:

```bash
ACTOR_INPUT_JSON='{"url":"https://httpbin.org/cache/60"}' python src/main.py
```

Alternatively write `storage/key_value_stores/default/INPUT.json`. Local dataset items appear in `storage/datasets/default/`. Input order is `ACTOR_INPUT_JSON`, default Apify key-value-store REST (when its ID is set), then local file.

### Limits and safety

- One public URL. HTTP(S) default ports only; all resolved addresses must be public. No login, forms, JS or cookies.
- One GET request, body **never read**, 12-second timeout; redirects **never followed**. A redirect is reported as its own response and the final URL is not guessed.
- Reports observed HTTP header values, not assumptions about a site's CDN or performance. Missing headers are `null`; invalid numeric values are `null`.
- Standard-library Python only, no Apify SDK, and no API keys supplied by the user.
- Live network behavior and Apify cloud build/storage integration remain to be tested on the platform; the supplied script-mode smoke run uses a deterministic fixture.

### Reproducible verification

```bash
python tests/run_smoke.py
python -m unittest discover -s tests -p 'test_*.py' -v
```

The smoke runner starts a **real subprocess** using `python src/main.py`, while its fixture transport returns deterministic headers. Actual stdout, stderr and output dataset JSON are included in `verification/`. The fixture is not an actual live httpbin header observation.

### Store listing

Category: `DEVELOPER_TOOLS` (only). Suggested price: **$0.002 per successful run**, advisory. No publishing or billing was configured.

# Actor input Schema

## `url` (type: `string`):

One public HTTP or HTTPS URL. Redirect targets are never fetched.

## Actor input object example

```json
{
  "url": "https://httpbin.org/cache/60"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "url": "https://httpbin.org/cache/60"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/http-cache-headers-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "url": "https://httpbin.org/cache/60" }

# Run the Actor and wait for it to finish
run = client.actor("eichan/http-cache-headers-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "url": "https://httpbin.org/cache/60"
}' |
apify call eichan/http-cache-headers-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/http-cache-headers-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LfhELkkf3nYLXQEUi/builds/IlLHasQw4CNo30ylq/openapi.json
