Skip to content

Instantly share code, notes, and snippets.

@ktopping
Created May 23, 2012 15:35
Show Gist options
  • Save ktopping/2775936 to your computer and use it in GitHub Desktop.
Save ktopping/2775936 to your computer and use it in GitHub Desktop.
cache headers
def images
... authenticate
... get @images from somewhere
... get user_id and brochure_id from somewhere
if stale?(:etag => Image.images_key(@images, "#{user_id},#{brochure_id}"))
respond_to do |format|
format.json {
response.headers['Cache-Control'] = 'public, max-age=2592000' # 1 month
render :content_type => "application/json"; # render via view
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment