Skip to content

Send real Last-Modified and honor If-Modified-Since → 304 #398

@eyeseast

Description

@eyeseast

Touch point: documentcloud/documents/views.py retrieve handler and
documentcloud/documents/models/document.py:115-117.

Document.updated_at = AutoLastModifiedField is the right freshness signal — confirmed not bumped on reads (no hit_count increment in the view). Two changes:

  • Set Last-Modified: <document.updated_at> instead of letting Django default to response time. DRF's Last-Modified mixin or a manual header set in the retrieve method both work.
  • Compare incoming If-Modified-Since to document.updated_at and return 304 Not Modified (no body) when nothing has changed.

Multiplied across daily scraper crawls of static archive content this is a large bandwidth win — and pairs naturally with stale-while-revalidate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions