Report abuse

app/controllers/application.rb


			
class ApplicationController < ActionController::Base
  # ...
  def with_etag_cache(*etag_params)
    response.etag = etag_params

    if request.fresh?(response)
      head :not_modified
    else
      yield
    end
  end
end

app/controllers/article.rb


			
class Article < ApplicationController
  def show
    with_etag_cache(:article, params[:id]) do
      # ... fetch and render; will be skipped if E-Tag matches
    end
  end
end