Skip to content

Age-based caching tiers #399

Description

@eyeseast

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions