prusswan (7) [Avatar] Offline
#1
The book listed:

fresh_when :last_modified => @ticket.updated_at, :etag => @ticket.to_s + current_user.id.to_s

But I was unable to get Completed 304 Not Modified with that (on Chrome which does send the If-None-Match header on refresh of the ticket page), and I believe the reason for that is that the @ticket = @project.tickets.find(params[:id]) returned from find_ticket is different even for the same params[:id] (ticket_id), so there will never be a cache hit based on such an etag scheme.

In the end I changed it to the following, which should work true to the intention of the example:

:etag => @project.id.to_s + @ticket.id.to_s + current_user.id.to_s


Then again, I could be wrong as the behavior of find_ticket might have been different in Rails 3.1 (I am using the latest Rails 3.2)