Skip to content

6.3: Add HTTP Caching Headers #98

@justin808

Description

@justin808

Overview

Configure proper HTTP caching for performance.

Parent Epic: #70
Priority: P2

Prerequisites

Next Issues (after this is complete)

  • 7.4: Add Production Configuration

Acceptance Criteria

  • Story list pages: Cache-Control with 1 minute max-age
  • Individual story pages: Cache-Control with 5 minute max-age
  • User pages: Cache-Control with 10 minute max-age
  • Proper Vary headers for content negotiation
  • ETag support for conditional requests (304 responses)
  • Verify caching works with curl/DevTools

Implementation Notes

# In controllers
class StoriesController < ApplicationController
  def index
    expires_in 1.minute, public: true
    # ...
  end
end

class ItemsController < ApplicationController
  def show
    @item = HackerNewsClient.fetch_item(params[:id])
    fresh_when(@item, public: true)
    expires_in 5.minutes, public: true
    # ...
  end
end

Consider using stale? for conditional GET support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HN-RSCHacker News RSC DemoRSCReact Server Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions