<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -44,6 +44,8 @@ end
 module Merb::Cache::ControllerInstanceMethods
   # Mixed in Merb::Controller. Provides methods related to page caching
 
+  DEFAULT_PAGE_EXTENSION = 'html'
+
   # Checks whether a cache entry exists
   #
   # ==== Parameter
@@ -54,9 +56,11 @@ module Merb::Cache::ControllerInstanceMethods
   #
   # ==== Example
   #   cached_page?(:action =&gt; 'show', :params =&gt; [params[:page]])
+  #   cached_page?(:action =&gt; 'show', :extension =&gt; 'js')
   def cached_page?(options)
     key = Merb::Controller._cache.key_for(options, controller_name, true)
-    File.file?(Merb::Controller._cache.config[:cache_html_directory] / &quot;#{key}.html&quot;)
+    extension = options[:extension] || DEFAULT_PAGE_EXTENSION
+    File.file?(Merb::Controller._cache.config[:cache_html_directory] / &quot;#{key}.#{extension}&quot;)
   end
 
   # Expires the page identified by the key computed after the parameters
@@ -67,13 +71,15 @@ module Merb::Cache::ControllerInstanceMethods
   # ==== Examples
   #   expire_page(:action =&gt; 'show', :controller =&gt; 'news')
   #   expire_page(:action =&gt; 'show', :match =&gt; true)
+  #   expire_page(:action =&gt; 'show', :extension =&gt; 'js')
   def expire_page(options)
     config_dir = Merb::Controller._cache.config[:cache_html_directory]
     Merb::Controller._cache.expire_key_for(options, controller_name, true) do |key, match|
       if match
         files = Dir.glob(config_dir / &quot;#{key}*&quot;)
       else
-        files = config_dir / &quot;#{key}.html&quot;
+        extension = options[:extension] || DEFAULT_PAGE_EXTENSION
+        files = config_dir / &quot;#{key}.#{extension}&quot;
       end
       FileUtils.rm_rf(files)
     end
@@ -106,16 +112,18 @@ module Merb::Cache::ControllerInstanceMethods
   #   If request.path is &quot;/&quot;, the name will be &quot;/index.html&quot;
   #   If request.path is &quot;/news/show/1&quot;, the name will be &quot;/news/show/1.html&quot;
   #   If request.path is &quot;/news/show/&quot;, the name will be &quot;/news/show.html&quot;
+  #   If request.path is &quot;/news/styles.css&quot;, the name will be &quot;/news/styles.css&quot;
   def _cache_page(data = nil)
-    cache_disable = Merb::Controller._cache.config[:disable]
-    return if cache_disable == true || cache_disable == Merb.environment
+    return if Merb::Controller._cache.config[:disable_page_caching]
     controller = controller_name
     action = action_name.to_sym
     pages = Merb::Controller._cache.cached_pages[controller]
     return unless pages &amp;&amp; pages.key?(action)
     path = request.path.chomp(&quot;/&quot;)
     path = &quot;index&quot; if path.empty?
-    cache_file = Merb::Controller._cache.config[:cache_html_directory] / &quot;#{path}.html&quot;
+    ext = &quot;.&quot; + (params[:format].empty? ? DEFAULT_PAGE_EXTENSION : params[:format])
+    ext = nil if File.extname(path) == ext
+    cache_file = Merb::Controller._cache.config[:cache_html_directory] / &quot;#{path}#{ext}&quot;
     if data
       cache_directory = File.dirname(cache_file)
       FileUtils.mkdir_p(cache_directory)</diff>
      <filename>merb-cache/lib/merb-cache/cache-page.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,6 +40,7 @@ class Merb::Cache
   def start
     @config = DEFAULT_CONFIG.merge(Merb::Plugins.config[:merb_cache] || {})
     if @config[:disable] == true || Merb.environment == @config[:disable]
+      config[:disable_page_caching] = true
       config[:store] = &quot;dummy&quot;
     end
     @config[:cache_html_directory] ||= Merb.dir_for(:public) / &quot;cache&quot;</diff>
      <filename>merb-cache/lib/merb-cache/merb-cache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,7 @@ class CacheController &lt; Merb::Controller
   cache_page :action5
   cache_page :action6, 0.05
   # or cache_pages :action5, [:action6, 0.05]
+  cache_page :action7
 
   def action1
     render
@@ -33,6 +34,24 @@ class CacheController &lt; Merb::Controller
     Time.now.to_s
   end
 
+  def action7
+    provides :js, :css, :html, :xml, :jpg
+    case params[:format]
+    when &quot;css&quot;
+      &quot;CSS&quot;
+    when &quot;js&quot;
+      &quot;JS&quot;
+    when &quot;html&quot;
+      &quot;HTML&quot;
+    when &quot;xml&quot;
+      &quot;XML&quot;
+    when &quot;jpg&quot;
+      &quot;JPG&quot;
+    else
+      raise &quot;BAD FORMAT: #{params[:format].inspect}&quot;
+    end
+  end
+
   def index
     &quot;test index&quot;
   end</diff>
      <filename>merb-cache/spec/controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -109,6 +109,38 @@ describe &quot;merb-cache-page&quot; do
     CACHE.cached_page?(:key =&gt; &quot;/cache_controller/action6/id1/id2&quot;).should be_false
   end
 
+  it &quot;should respect original content-type&quot; do
+    c = get(&quot;/cache_controller/action7.css&quot;)
+    c.body.should == &quot;CSS&quot;
+    c = get(&quot;/cache_controller/action7.css&quot;)
+    c.params[:format].should == &quot;css&quot;
+    c.cached_page?(:action =&gt; &quot;action7&quot;, :extension =&gt; 'css').should be_true
+
+    c = get(&quot;/cache_controller/action7.js&quot;)
+    c.body.should == &quot;JS&quot;
+    c = get(&quot;/cache_controller/action7.js&quot;)
+    c.params[:format].should == &quot;js&quot;
+    c.cached_page?(:action =&gt; &quot;action7&quot;, :extension =&gt; 'js').should be_true
+
+    c = get(&quot;/cache_controller/action7.xml&quot;)
+    c.body.should == &quot;XML&quot;
+    c = get(&quot;/cache_controller/action7.xml&quot;)
+    c.params[:format].should == &quot;xml&quot;
+    c.cached_page?(:action =&gt; &quot;action7&quot;, :extension =&gt; 'xml').should be_true
+
+    c = get(&quot;/cache_controller/action7.jpg&quot;)
+    c.body.should == &quot;JPG&quot;
+    c = get(&quot;/cache_controller/action7.jpg&quot;)
+    c.params[:format].should == &quot;jpg&quot;
+    c.cached_page?(:action =&gt; &quot;action7&quot;, :extension =&gt; 'jpg').should be_true
+
+    c = get(&quot;/cache_controller/action7.html&quot;)
+    c.body.should == &quot;HTML&quot;
+    c = get(&quot;/cache_controller/action7.html&quot;)
+    c.params[:format].should == &quot;html&quot;
+    c.cached_page?(:action =&gt; &quot;action7&quot;).should be_true
+  end
+
   it &quot;should expire all pages&quot; do
     CACHE.expire_all_pages
     CACHE.cached_page?(&quot;action6&quot;).should be_false</diff>
      <filename>merb-cache/spec/merb-cache-page_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>47d372f6a6f195974792a76554ccab41b324b2a9</id>
    </parent>
  </parents>
  <author>
    <name>booss</name>
    <email>alex.boussinet@gmail.com</email>
  </author>
  <url>http://github.com/wycats/merb-more/commit/8690d673201d6cff9019dc26291af773eafdb4a0</url>
  <id>8690d673201d6cff9019dc26291af773eafdb4a0</id>
  <committed-date>2008-04-29T05:17:11-07:00</committed-date>
  <authored-date>2008-04-29T05:17:11-07:00</authored-date>
  <message>Cached page requests now respect the original content-type, fixing #116</message>
  <tree>39812c00c36a053cb789115923e5ac0cba2366db</tree>
  <committer>
    <name>booss</name>
    <email>alex.boussinet@gmail.com</email>
  </committer>
</commit>
