module ActionController::ConditionalGet::ClassMethods
def etag(&etagger)
end
fresh_when etag: @invoice
@invoice = Invoice.find(params[:id])
# Etag will differ even for the same invoice when it's viewed by a different current_user
def show
etag { current_user&.id }
class InvoicesController < ApplicationController
of cached pages.
may want to add the current user id to be part of the ETag to prevent unauthorized displaying
For example, if you serve pages tailored depending on who's logged in at the moment, you
Allows you to consider additional controller-wide information when generating an ETag.
def etag(&etagger) self.etaggers += [etagger] end