From ddd0cd9f74e266b807366b6def3b18db183b3cf7 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Wed, 22 Aug 2012 20:26:20 +0200 Subject: [PATCH] HTTP caching for asciicast json data --- app/controllers/asciicasts_controller.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/controllers/asciicasts_controller.rb b/app/controllers/asciicasts_controller.rb index f5b962c..da241d7 100644 --- a/app/controllers/asciicasts_controller.rb +++ b/app/controllers/asciicasts_controller.rb @@ -36,9 +36,21 @@ class AsciicastsController < ApplicationController def show @asciicast = AsciicastDecorator.new(@asciicast) - @asciicast_author = UserDecorator.new(@asciicast.user) - @title = @asciicast.smart_title - respond_with @asciicast + + respond_to do |format| + format.html do + @asciicast_author = UserDecorator.new(@asciicast.user) + @title = @asciicast.smart_title + respond_with @asciicast + end + + format.json do + if stale? @asciicast + respond_with @asciicast + end + end + end + end def edit