# Cache-Control response policy of HTML documents

**URL:** <https://discuss.httparchive.org/t/cache-control-response-policy-of-html-documents/310>\
**Category:** Analysis\
**Created:** [July 13, 2014, 11:47am UTC](https://discuss.httparchive.org/t/cache-control-response-policy-of-html-documents/310 "2014-07-13T11:47:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![igrigorik](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/igrigorik/32/925_2.png) [@igrigorik](https://discuss.httparchive.org/u/igrigorik)\
**Post date:** [July 13, 2014, 11:47am UTC](https://discuss.httparchive.org/t/cache-control-response-policy-of-html-documents/310/1 "2014-07-13T11:47:09Z")

</div>

```sql
SELECT policy, COUNT(policy) as policy_count,
RATIO_TO_REPORT(policy_count) OVER() as ratio FROM (
  SELECT resp_cache_control, resp_expires, 
    CASE
      WHEN resp_cache_control CONTAINS "no-store" 
        THEN "no-store"
      WHEN resp_cache_control CONTAINS "no-cache"
        OR resp_cache_control CONTAINS "max-age=0"
        OR resp_expires = "-1" 
        THEN "non-cacheable"
      WHEN LENGTH(resp_cache_control) = 0 
        AND LENGTH(resp_expires) = 0 
        THEN "undefined"
      ELSE "cacheable"
      END as policy
  FROM [runs.latest_requests] 
  WHERE firstHtml = true
) GROUP BY policy
ORDER BY policy_count DESC

```

For 2014-06-15 run, the stats are:  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/httparchive/312/ad3ca1c12966b6c5.png)

Note that “non-cacheable” means “no-store” was not specified, but the reverse does not hold.

---

<div class="post-metadata">

**Author:** ![stevesoudersorg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/stevesoudersorg/32/1293_2.png) [@stevesoudersorg](https://discuss.httparchive.org/u/stevesoudersorg)\
**Post date:** [July 13, 2014, 3:56pm UTC](https://discuss.httparchive.org/t/cache-control-response-policy-of-html-documents/310/2 "2014-07-13T15:56:32Z")

</div>

Hi, Ilya. Can you clarify what you’re trying to measure? I see “firstHtml = true”. Is this the caching policies only for the main HTML document? If so, the high percentage of “no-store” and “non-cacheable” is understandable. The high percentage of “undefined” is bad - it’s better to specify explicit caching headers rather than leave it up to browser heuristics (which vary by browser).

---

<div class="post-metadata">

**Author:** ![igrigorik](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/igrigorik/32/925_2.png) [@igrigorik](https://discuss.httparchive.org/u/igrigorik)\
**Post date:** [July 13, 2014, 5:01pm UTC](https://discuss.httparchive.org/t/cache-control-response-policy-of-html-documents/310/3 "2014-07-13T17:01:39Z")

</div>

Yep, good catch, updated the title of the post. Was trying to get a feel for CC policies of the HTML documents, and I’m with you on relying on heuristic caching.

A deeper look at the docs that **do** specify the max-age:

```sql
SELECT 
  INTEGER(REGEXP_EXTRACT(resp_cache_control, r'max-age=(\d+)')) age, 
  count(pageid) cnt,
  RATIO_TO_REPORT(cnt) OVER() as ratio
FROM [httparchive:runs.latest_requests]
WHERE firstHtml = true
  AND resp_cache_control CONTAINS 'max-age'
GROUP BY age
HAVING cnt > 500
ORDER BY age asc

```

![](https://yyz1.discourse-cdn.com/flex035/uploads/httparchive/313/938df29cfaf35dff.png)

50% mark the doc as non-cacheable, followed by spikes at 3s (hmm), 10m, 1hr, and 1 day.
