Skip to content

Commit

Permalink
Don't cache pages in dev mode. This is how it was before the switch t…
Browse files Browse the repository at this point in the history
…o Rack::Cache in Radiant 0.8.
  • Loading branch information
jgarber committed Sep 30, 2009
1 parent 78b394d commit 4d2ff81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/site_controller.rb
Expand Up @@ -29,7 +29,7 @@ def show_page

private
def set_cache_control
if (request.head? || request.get?) && @page.cache?
if (request.head? || request.get?) && @page.cache? && live?
expires_in self.class.cache_timeout, :public => true, :private => false
else
expires_in nil, :private => true, "no-cache" => true
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/site_controller_spec.rb
Expand Up @@ -116,6 +116,15 @@
response.headers['ETag'].should be_blank
end

it "should prevent upstream caching in dev mode" do
request.host = "dev.site.com"

get :show_page, :url => '/'
response.headers['Cache-Control'].should =~ /private/
response.headers['Cache-Control'].should =~ /no-cache/
response.headers['ETag'].should be_blank
end

it "should set the default cache timeout (max-age) to a value assigned by the user" do
SiteController.cache_timeout = 10.minutes
get :show_page, :url => '/'
Expand Down

0 comments on commit 4d2ff81

Please sign in to comment.