Skip to content

Commit

Permalink
Cache product API responses for 3 minutes to make things like Backbon…
Browse files Browse the repository at this point in the history
…e cache them
  • Loading branch information
radar committed Aug 9, 2013
1 parent ac87629 commit a9dcfe4
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions api/app/controllers/spree/api/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ def index
end

@products = @products.page(params[:page]).per(params[:per_page])
last_updated_product = Spree::Product.order("updated_at ASC").last
if stale?(:etag => last_updated_product, :last_modified => last_updated_product.updated_at)
respond_with(@products)
end
end

def show
@product = find_product(params[:id])
expires_in 3.minutes
respond_with(@product)
end

Expand Down

0 comments on commit a9dcfe4

Please sign in to comment.