<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,12 +12,13 @@ module Mack
           page = Cachetastic::Caches::PageCache.get(request.fullpath)
           if page
             response = Mack::Response.new
+            response[&quot;Content-Type&quot;] = page.content_type
             response.write(page.body)
             return response.finish
           end
           ret = @app.call(env)
           res = ret[2]
-          Cachetastic::Caches::PageCache.set(request.fullpath, Mack::Caching::PageCaching::Page.new(res.body))
+          Cachetastic::Caches::PageCache.set(request.fullpath, Mack::Caching::PageCaching::Page.new(res.body, res[&quot;Content-Type&quot;])) if res.successful?
           return ret
         end
         return @app.call(env)
@@ -27,9 +28,8 @@ module Mack
         
         attr_reader :body
         attr_reader :content_type
-        attr_reader :status
         
-        def initialize(body, content_type = &quot;text/html&quot;, status = 200)
+        def initialize(body, content_type = &quot;text/html&quot;)
           if body.is_a?(Array)
             raise Mack::Caching::PageCaching::UncacheableError.new(&quot;Multipart pages can not be cached!&quot;) if body.size &gt; 1
             @body = body.first
@@ -37,7 +37,6 @@ module Mack
             @body = body
           end
           @content_type = content_type
-          @status = status
         end
         
         def to_s</diff>
      <filename>mack-caching/lib/page_caching.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,5 +4,18 @@ class DefaultController
   # /
   def index
   end
+  
+  def hello_world
+    wants(:xml) do
+      render(:text, &quot;&lt;name&gt;#{params[:name]}&lt;/name&gt;&lt;rand&gt;#{rand}&lt;/rand&gt;&quot;)
+    end
+    wants(:html) do
+      render(:text, &quot;&lt;p&gt;#{params[:name]}&lt;/p&gt;&lt;p&gt;#{rand}&lt;/p&gt;&quot;)
+    end
+  end
+  
+  def always_500
+    render(:text, &quot;i should be 500: #{rand}&quot;, :status =&gt; 500)
+  end
 
 end</diff>
      <filename>mack-caching/spec/fake_application/app/controllers/default_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,3 +4,5 @@ mack::session_id: _fake_application_session_id
 
 orm: data_mapper
 mack::testing_framework: rspec
+
+use_page_caching: true
\ No newline at end of file</diff>
      <filename>mack-caching/spec/fake_application/config/app_config/default.yml</filename>
    </modified>
    <modified>
      <diff>@@ -9,39 +9,60 @@ describe &quot;Page Caching&quot; do
   describe &quot;use_page_caching is turned on&quot; do
   
     it &quot;should serve a cached page&quot; do
-      temp_app_config(:use_page_caching =&gt; true) do
-        Cachetastic::Caches::PageCache.set(&quot;/&quot;, Mack::Caching::PageCaching::Page.new(&quot;hello&quot;))
-        get &quot;/&quot;
-        response.body.should == &quot;hello&quot;
-      end
+      Cachetastic::Caches::PageCache.set(&quot;/&quot;, Mack::Caching::PageCaching::Page.new(&quot;hello&quot;))
+      get &quot;/&quot;
+      response.body.should == &quot;hello&quot;
+      response.content_type.should == &quot;text/html&quot;
     end
     
     it &quot;should cache a page designated to be cached&quot; do
-      temp_app_config(:use_page_caching =&gt; true) do
-        get &quot;/&quot;
-        response.body.should match(/Welcome to your Mack application!/)
-        Cachetastic::Caches::PageCache.get(&quot;/&quot;).to_s.should == response.body
-      end
+      get &quot;/default/hello_world?name=mark&quot;
+      response.body.should match(/&lt;p&gt;mark&lt;\/p&gt;/)
+      page = Cachetastic::Caches::PageCache.get(&quot;/default/hello_world?name=mark&quot;)
+      page.to_s.should == response.body
+      page.content_type.should == &quot;text/html&quot;
     end
     
-    it &quot;should store the content type correctly&quot;
+    it &quot;should store and deliver the content type correctly&quot; do
+      get &quot;/default/hello_world.xml?name=mark&quot;
+      response.body.should match(/&lt;name&gt;mark&lt;\/name&gt;/)
+      response.content_type.should == &quot;application/xml; text/xml&quot;
+      old_body = response.body
+      get &quot;/default/hello_world.xml?name=mark&quot;
+      response.body.should == old_body
+      response.content_type.should == &quot;application/xml; text/xml&quot;
+    end
     
-    it &quot;should deliver the content type correctly&quot;
     
-    it &quot;should store the status correctly&quot;
+    it &quot;should never store non-successful pages&quot; do
+      get &quot;/default/always_500&quot;
+      response.status.should == 500
+      Cachetastic::Caches::PageCache.get(&quot;/default/always_500&quot;).should be_nil
+    end
     
-    it &quot;should deliver the status correctly&quot;
     
   end
   
   describe &quot;use_page_caching is turned off&quot; do
   
     it &quot;should serve the uncached page&quot; do
-      get &quot;/&quot;
-      response.body.should match(/Welcome to your Mack application!/)
+      temp_app_config(&quot;use_page_caching&quot; =&gt; false) do
+        get &quot;/default/hello_world?name=mark&quot;
+        response.body.should match(/&lt;p&gt;mark&lt;\/p&gt;/)
+        old_body = response.body
+        get &quot;/default/hello_world?name=mark&quot;
+        response.body.should match(/&lt;p&gt;mark&lt;\/p&gt;/)
+        response.body.should_not == old_body
+      end
     end
     
-    it &quot;should not store the cached page&quot;
+    it &quot;should not store the cached page&quot; do
+      temp_app_config(&quot;use_page_caching&quot; =&gt; false) do
+        get &quot;/default/hello_world?name=mark&quot;
+        response.body.should match(/&lt;p&gt;mark&lt;\/p&gt;/)
+        Cachetastic::Caches::PageCache.get(&quot;/default/hello_world?name=mark&quot;).should be_nil
+      end
+    end
     
   end
   </diff>
      <filename>mack-caching/spec/lib/page_caching_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d16c138c3927367c222babacf543cfa125c8d42d</id>
    </parent>
  </parents>
  <author>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </author>
  <url>http://github.com/markbates/mack-more/commit/e5c2e8ade1ef1dcef5344ec8a9f0662d4ee2717c</url>
  <id>e5c2e8ade1ef1dcef5344ec8a9f0662d4ee2717c</id>
  <committed-date>2008-07-18T09:38:30-07:00</committed-date>
  <authored-date>2008-07-18T09:38:30-07:00</authored-date>
  <message>Feature: Page Caching [#18 state:resolved]</message>
  <tree>a2ec3c2c4a39afc59ff242b51cb21dd19ae00f3d</tree>
  <committer>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </committer>
</commit>
