Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created August 10, 2008 20:15
Show Gist options
  • Save joevandyk/4762 to your computer and use it in GitHub Desktop.
Save joevandyk/4762 to your computer and use it in GitHub Desktop.
class FeedController < ApplicationController
after_filter :remember_cache
before_filter :check_for_cache
def blog
@blogs = Blog.last_few_blogs 10
response.headers["Content-Type" ] = "text/xml;"
render :layout => false
end
def products
@product = Product.current_product_for_sale
response.headers["Content-Type" ] = "text/xml;"
render :layout => false
end
def magazine
@product = Magazine.current
response.headers["Content-Type" ] = "text/xml;"
render :layout => false, :action => 'products'
end
def bottom_feeder
@product = BottomFeeder.current
render :layout => false
end
private
def check_for_cache
result = CACHE.get(cache_location)
if result
render :xml => result
return false
end
end
def remember_cache
CACHE.set(cache_location, response.body, 60)
end
def cache_location
"feeds:" + @action_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment