{"skills":[{"name":"Interpret cache freshness from response headers","description":"Determine whether a stored response with an explicit caching policy may be reused at a stated age.","content":"# Interpret cache freshness from response headers\n\nDetermine whether a stored response with an explicit caching policy may be reused at a stated age.\n\n## When to use this skill\n\n- Someone has response headers and asks how long a browser or CDN may reuse the response.\n- A CDN or proxy serves stale content, or revalidates on every request, and the team wants to know what the headers allow.\n- A developer is choosing between no-cache, no-store, max-age and s-maxage and wants to check what a given header will do.\n\n## When not to use it\n\n- Vendor-specific CDN settings and targeted headers such as Surrogate-Control or CDN-Cache-Control, which can override the standard ones. Check that vendor's documentation.\n- Responses with no explicit lifetime. RFC 9111 lets caches estimate a heuristic lifetime, often from Last-Modified, so the answer depends on that cache's own algorithm.\n- Back and forward navigation in a browser, which can restore a page from the back\/forward cache without revalidating.\n\n## What you need\n\n- Cache type, response Cache-Control and either calculated current age or the request, response and assessment times with Date and Age evidence.\n- A simple cacheable GET response and any request directives, status or validation conditions that alter reuse.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Is the cache a private browser cache or a shared cache such as a CDN or proxy? s-maxage and private apply differently to each.\n- Can you supply all the response headers (Cache-Control, Expires, Date, Age, Vary, ETag or Last-Modified) and the request headers, including any Cache-Control or Authorization?\n- Do you know the response's current age, or the request, response and assessment times? Freshness compares age with lifetime.\n- Is it a GET with a cacheable status such as 200? Other methods and statuses have their own rules.\n\n## Method\n\n1. Confirm the basics: a GET (or other cacheable method) with a cacheable status, and whether the cache is private or shared. A shared cache must not store a response to a request carrying Authorization unless a directive such as public, s-maxage or must-revalidate allows it.\n2. Check storage first. no-store on the response means do-not-store. An unqualified private directive means a shared cache must not store the response; a browser cache may.\n3. Check mandatory validation. Unqualified no-cache on the response means every reuse must be validated with the origin, even while fresh. A no-cache request directive asks for validation before reuse. Either gives validate.\n4. Find the freshness lifetime, first match wins: s-maxage in a shared cache, then max-age, then Expires minus Date (or minus the receipt time if Date is absent). Ignore Expires when max-age is present, and in a shared cache when s-maxage is present. An invalid Expires such as 0 means already expired.\n5. Find the current age. Use the cache's calculated age if supplied. Otherwise apparent_age = max(0, response_time \u2212 Date); corrected_age_value = Age + (response_time \u2212 request_time), with Age 0 if absent; corrected_initial_age is the larger of the two; current_age = corrected_initial_age + (now \u2212 response_time).\n6. Compare: the response is fresh only while the lifetime is greater than the current age; equal or less is stale. Remaining time is lifetime minus age, never below zero.\n7. Resolve conflicts as RFC 9111 says: honour the most restrictive directive, and for duplicate lifetime values either use the first or treat the response as stale, reporting undetermined if those differ and the cache's behaviour is unknown. Without an explicit lifetime, report undetermined rather than guessing a heuristic. Name any request directive (max-age, max-stale, min-fresh) or extension such as stale-while-revalidate that was not applied.\n\n## Checks before you deliver\n\n- no-cache permits storage with revalidation. Treating it as no-store misdiagnoses a normal conditional request.\n- An unqualified private directive applies to shared storage. Do not apply it as a blanket ban on a browser cache.\n- Using Expires when max-age is present gives the wrong lifetime. A recipient must ignore Expires whenever max-age is present.\n- The Age header alone is not the current age. Add the delay in transit and the time the response has been stored.\n- Treating an age equal to the lifetime as fresh. A response is fresh only while its lifetime is greater than its age.\n- must-revalidate does not stop reuse while the response is fresh. It forbids serving it stale once the lifetime has passed, even when the origin cannot be reached.\n\n## How to present the result\n\nLead with the decision for the named cache: fresh with N seconds left, stale, validate, do not store or undetermined. Then show the working in a few lines: which directive set the lifetime, how the age was calculated and the comparison. Finish with what will happen on the next request and, if that is not what was intended, the Cache-Control value that would achieve it.\n\n## Worked example\n\n**Request:** Assess a cacheable GET in a shared cache. No request modifiers or stale extensions.\n\n**Supplied material:**\n\n```text\nCache-Control: public, max-age=600, s-maxage=60\nCalculated current age: 60 seconds\n```\n\n**Answer:** The CDN\u2019s copy is stale. Its shared-cache lifetime is 60 seconds and its current age is exactly 60 seconds, leaving no fresh time. Validate it or fetch a fresh response before ordinary reuse.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn decision as do-not-store, validate, fresh, stale or undetermined. Return lifetime_seconds and remaining_seconds as integers where the applicable explicit lifetime can be used, otherwise null. For validate and do-not-store use null for both. Clamp a stale remaining lifetime to zero.\n\n## Sources\n\n- [RFC 9111, HTTP caching](https:\/\/www.rfc-editor.org\/rfc\/rfc9111.html): The HTTP caching standard. Section 4.2.1 gives the lifetime order (s-maxage in shared caches, max-age, then Expires minus Date) and the rules for duplicates and conflicts; Section 4.2.3 gives the age calculation; Section 5 defines no-store, no-cache, private, must-revalidate and the rule to ignore Expires when max-age is present.\n- [MDN Cache-Control reference](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Reference\/Headers\/Cache-Control): Explains each directive in practical terms, including that private caches ignore s-maxage, that s-maxage overrides max-age and Expires in shared caches, and that no-cache allows storage but needs validation before each reuse.\n- [MDN HTTP caching guide](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Guides\/Caching): Describes private and shared caches, heuristic caching when no lifetime is given, and notes that no-cache does not guarantee revalidation for history navigations such as the Back button, which is why those cases are outside this check.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/interpret-http-cache-freshness\n","scope":"contextual","trigger_keywords":["Interpret cache freshness from response headers","interpret-http-cache-freshness","interpret http cache freshness","How long can a browser or CDN reuse this response, going by its headers?","How long can a browser or CDN reuse this response, going by its headers","http cache freshness","is this cached response stale","freshness of this cached response"],"is_private":true,"is_active":true,"scripts":[{"name":"interpret-http-cache-freshness-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"interpret-http-cache-freshness-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: interpret-http-cache-freshness\ndescription: \"Decide whether a stored HTTP response may be reused, must be revalidated or must not be stored, by applying RFC 9111 to its Cache-Control, Expires, Date and Age headers for a browser or shared cache. Use when someone asks if a cached page or API response is fresh or stale.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/interpret-http-cache-freshness\n---\n\n# Interpret cache freshness from response headers\n\nDetermine whether a stored response with an explicit caching policy may be reused at a stated age.\n\n## When to use this skill\n\n- Someone has response headers and asks how long a browser or CDN may reuse the response.\n- A CDN or proxy serves stale content, or revalidates on every request, and the team wants to know what the headers allow.\n- A developer is choosing between no-cache, no-store, max-age and s-maxage and wants to check what a given header will do.\n\n## When not to use it\n\n- Vendor-specific CDN settings and targeted headers such as Surrogate-Control or CDN-Cache-Control, which can override the standard ones. Check that vendor's documentation.\n- Responses with no explicit lifetime. RFC 9111 lets caches estimate a heuristic lifetime, often from Last-Modified, so the answer depends on that cache's own algorithm.\n- Back and forward navigation in a browser, which can restore a page from the back\/forward cache without revalidating.\n\n## What you need\n\n- Cache type, response Cache-Control and either calculated current age or the request, response and assessment times with Date and Age evidence.\n- A simple cacheable GET response and any request directives, status or validation conditions that alter reuse.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- Is the cache a private browser cache or a shared cache such as a CDN or proxy? s-maxage and private apply differently to each.\n- Can you supply all the response headers (Cache-Control, Expires, Date, Age, Vary, ETag or Last-Modified) and the request headers, including any Cache-Control or Authorization?\n- Do you know the response's current age, or the request, response and assessment times? Freshness compares age with lifetime.\n- Is it a GET with a cacheable status such as 200? Other methods and statuses have their own rules.\n\n## Method\n\n1. Confirm the basics: a GET (or other cacheable method) with a cacheable status, and whether the cache is private or shared. A shared cache must not store a response to a request carrying Authorization unless a directive such as public, s-maxage or must-revalidate allows it.\n2. Check storage first. no-store on the response means do-not-store. An unqualified private directive means a shared cache must not store the response; a browser cache may.\n3. Check mandatory validation. Unqualified no-cache on the response means every reuse must be validated with the origin, even while fresh. A no-cache request directive asks for validation before reuse. Either gives validate.\n4. Find the freshness lifetime, first match wins: s-maxage in a shared cache, then max-age, then Expires minus Date (or minus the receipt time if Date is absent). Ignore Expires when max-age is present, and in a shared cache when s-maxage is present. An invalid Expires such as 0 means already expired.\n5. Find the current age. Use the cache's calculated age if supplied. Otherwise apparent_age = max(0, response_time \u2212 Date); corrected_age_value = Age + (response_time \u2212 request_time), with Age 0 if absent; corrected_initial_age is the larger of the two; current_age = corrected_initial_age + (now \u2212 response_time).\n6. Compare: the response is fresh only while the lifetime is greater than the current age; equal or less is stale. Remaining time is lifetime minus age, never below zero.\n7. Resolve conflicts as RFC 9111 says: honour the most restrictive directive, and for duplicate lifetime values either use the first or treat the response as stale, reporting undetermined if those differ and the cache's behaviour is unknown. Without an explicit lifetime, report undetermined rather than guessing a heuristic. Name any request directive (max-age, max-stale, min-fresh) or extension such as stale-while-revalidate that was not applied.\n\n## Checks before you deliver\n\n- no-cache permits storage with revalidation. Treating it as no-store misdiagnoses a normal conditional request.\n- An unqualified private directive applies to shared storage. Do not apply it as a blanket ban on a browser cache.\n- Using Expires when max-age is present gives the wrong lifetime. A recipient must ignore Expires whenever max-age is present.\n- The Age header alone is not the current age. Add the delay in transit and the time the response has been stored.\n- Treating an age equal to the lifetime as fresh. A response is fresh only while its lifetime is greater than its age.\n- must-revalidate does not stop reuse while the response is fresh. It forbids serving it stale once the lifetime has passed, even when the origin cannot be reached.\n\n## How to present the result\n\nLead with the decision for the named cache: fresh with N seconds left, stale, validate, do not store or undetermined. Then show the working in a few lines: which directive set the lifetime, how the age was calculated and the comparison. Finish with what will happen on the next request and, if that is not what was intended, the Cache-Control value that would achieve it.\n\n## Worked example\n\n**Request:** Assess a cacheable GET in a shared cache. No request modifiers or stale extensions.\n\n**Supplied material:**\n\n```text\nCache-Control: public, max-age=600, s-maxage=60\nCalculated current age: 60 seconds\n```\n\n**Answer:** The CDN\u2019s copy is stale. Its shared-cache lifetime is 60 seconds and its current age is exactly 60 seconds, leaving no fresh time. Validate it or fetch a fresh response before ordinary reuse.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn decision as do-not-store, validate, fresh, stale or undetermined. Return lifetime_seconds and remaining_seconds as integers where the applicable explicit lifetime can be used, otherwise null. For validate and do-not-store use null for both. Clamp a stale remaining lifetime to zero.\n\n## Sources\n\n- [RFC 9111, HTTP caching](https:\/\/www.rfc-editor.org\/rfc\/rfc9111.html): The HTTP caching standard. Section 4.2.1 gives the lifetime order (s-maxage in shared caches, max-age, then Expires minus Date) and the rules for duplicates and conflicts; Section 4.2.3 gives the age calculation; Section 5 defines no-store, no-cache, private, must-revalidate and the rule to ignore Expires when max-age is present.\n- [MDN Cache-Control reference](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Reference\/Headers\/Cache-Control): Explains each directive in practical terms, including that private caches ignore s-maxage, that s-maxage overrides max-age and Expires in shared caches, and that no-cache allows storage but needs validation before each reuse.\n- [MDN HTTP caching guide](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Guides\/Caching): Describes private and shared caches, heuristic caching when no lifetime is given, and notes that no-cache does not guarantee revalidation for history navigations such as the Back button, which is why those cases are outside this check.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/interpret-http-cache-freshness\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/interpret-http-cache-freshness\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# CDN at the expiry boundary\n\nAssess a cacheable GET in a shared cache. No request modifiers or stale extensions.\n\n## Supplied material\n\nCache-Control: public, max-age=600, s-maxage=60\nCalculated current age: 60 seconds\n\n## Worked answer\n\nThe CDN\u2019s copy is stale. Its shared-cache lifetime is 60 seconds and its current age is exactly 60 seconds, leaving no fresh time. Validate it or fetch a fresh response before ordinary reuse.\n\n## Reasoning\n\nThe shared limit overrides max-age. Equality is already stale.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"Assess a cacheable GET in a shared cache. No request modifiers or stale extensions.\nReturn only the JSON specified in SKILL.md for this test.\n\nCache-Control: public, max-age=600, s-maxage=60\nCalculated current age: 60 seconds\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"decision\": \"stale\",\n    \"lifetime_seconds\": 60,\n    \"remaining_seconds\": 0\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"The shared limit overrides max-age. Equality is already stale.\n"},{"path":"tests\/case-2\/request.txt","content":"Assess a cacheable GET in a private browser cache. No request modifiers.\nReturn only the JSON specified in SKILL.md for this test.\n\nCache-Control: private, no-cache, max-age=7200\nCalculated current age: 2 seconds\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"decision\": \"validate\",\n    \"lifetime_seconds\": null,\n    \"remaining_seconds\": null\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"The stored browser response needs validation before reuse regardless of its age.\n"},{"path":"tests\/case-3\/request.txt","content":"Assess this ordinary cacheable GET. No request modifiers or stale allowances. All timestamps are on the same day in UTC.\nReturn only the JSON specified in SKILL.md for this test.\n\nCache-Control: max-age=30\nRequest sent 12:00:00. Date 12:00:00. Response received 12:00:08. Age: 10. Assessment at 12:00:20.\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"decision\": \"stale\",\n    \"lifetime_seconds\": 30,\n    \"remaining_seconds\": 0\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"The received age plus transit is 18 seconds, which exceeds the apparent age of 8. Adding 12 seconds of residence gives a current age of 30.\n"},{"path":"tests\/case-4\/request.txt","content":"Assess a cacheable GET in a browser cache with no request restrictions.\nReturn only the JSON specified in SKILL.md for this test.\n\nDate: Tue, 10 Nov 2026 12:00:00 GMT\nExpires: Tue, 10 Nov 2026 12:02:00 GMT\nCache-Control: public\nCalculated current age: 85 seconds.\n"},{"path":"tests\/case-4\/expected.json","content":"{\n    \"decision\": \"fresh\",\n    \"lifetime_seconds\": 120,\n    \"remaining_seconds\": 35\n}\n"},{"path":"tests\/case-4\/explanation.txt","content":"No max-age applies. Expires is two minutes after Date, leaving 35 seconds of fresh time.\n"}],"is_active":true,"is_approved":false}]}]}