Created
August 10, 2008 20:15
-
-
Save joevandyk/4762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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