Touch point: documentcloud/documents/decorators.py:27-43, config/settings/base.py:584 (CACHE_CONTROL_MAX_AGE).
Replace the constant CACHE_CONTROL_MAX_AGE with a tier function keyed off document.updated_at:
| Age bucket |
max-age (browser) |
s-maxage (CDN) |
Extras |
| Edited < 24h |
60 |
300 |
— |
| Edited < 7d |
300 |
3600 |
— |
| Edited < 90d |
3600 |
86400 |
stale-while-revalidate=3600 |
| Edited 90d – 5y |
86400 |
2592000 |
stale-while-revalidate=86400 |
| Edited > 5y |
86400 |
31536000 |
stale-while-revalidate=86400 |
Implementation note: the decorator currently operates without view-level data. The cleanest place to compute the tier is inside the retrieve view (where the Document instance is in hand), setting response["Cache-Control"] directly after serialization. Keep the existing anonymous_cache_control decorator for routes that don't have a single object (list, search) — they should continue to be no-store.
Touch point:
documentcloud/documents/decorators.py:27-43,config/settings/base.py:584(CACHE_CONTROL_MAX_AGE).Replace the constant
CACHE_CONTROL_MAX_AGEwith a tier function keyed offdocument.updated_at:max-age(browser)s-maxage(CDN)stale-while-revalidate=3600stale-while-revalidate=86400stale-while-revalidate=86400Implementation note: the decorator currently operates without view-level data. The cleanest place to compute the tier is inside the retrieve view (where the
Documentinstance is in hand), settingresponse["Cache-Control"]directly after serialization. Keep the existinganonymous_cache_controldecorator for routes that don't have a single object (list, search) — they should continue to beno-store.