Permalink
Browse files

Fix broken caching.

  • Loading branch information...
1 parent 60bd5bd commit beb96ee44817315bf4258222fe0394580204a929 @jgarber committed Oct 31, 2008
Showing with 18 additions and 14 deletions.
  1. +4 −0 app/models/site.rb
  2. +14 −14 lib/cache_by_domain.rb
View
@@ -5,4 +5,8 @@ class Site < ActiveRecord::Base
def allow_access_for(user)
user.admin? || self.users.include?(user)
end
+
+ def homepage
+ self.pages.find(:first,:conditions => {:parent_id => nil})
+ end
end
View
@@ -14,7 +14,7 @@ def show_page
cache_key = cache_key_for_url(url) # Use cache_key, not raw URL
- if (request.get? || request.head?) and live? and (@cache.response_cached?(url))
+ if (request.get? || request.head?) and live? and (@cache.response_cached?(cache_key))
@cache.update_response(cache_key, response, request)
@performed_render = true
else
@@ -28,17 +28,17 @@ def cache_key_for_url(url)
"#{request.host}/#{url}"
end
- # def show_uncached_page(url)
- # @page = find_page(url)
- # unless @page.nil?
- # process_page(@page)
- # cache_key = cache_key_for_url(url) # Use cache key, not raw URL
- # @cache.cache_response(cache_key, response) if request.get? and live? and @page.cache?
- # @performed_render = true
- # else
- # render :template => 'site/not_found', :status => 404
- # end
- # rescue Page::MissingRootPageError
- # redirect_to welcome_url
- # end
+ def show_uncached_page(url)
+ @page = find_page(url)
+ unless @page.nil?
+ process_page(@page)
+ cache_key = cache_key_for_url(url) # Use cache key, not raw URL
+ @cache.cache_response(cache_key, response) if request.get? and live? and @page.cache?
+ @performed_render = true
+ else
+ render :template => 'site/not_found', :status => 404
+ end
+ rescue Page::MissingRootPageError
+ redirect_to welcome_url
+ end
end

0 comments on commit beb96ee

Please sign in to comment.