This project is archived and is in readonly mode.

#1585 ✓resolved
Mislav

action caching sets wrong content-type when :cache_path is a string

Reported by Mislav | December 17th, 2008 @ 01:32 PM

If someone uses a string for :cache_path


caches_action :show, :cache_path => 'http://test.host/custom/show'

action caching will be broken for content types other than "text/html".

Patch: http://gist.github.com/37050

Similar bug seems to affect page caching: #1244

Comments and changes to this ticket

  • Michael Koziarski

    Michael Koziarski December 17th, 2008 @ 01:46 PM

    • Milestone cleared.
    • Assigned user set to “Michael Koziarski”
  • Christoph Petschnig

    Christoph Petschnig February 26th, 2009 @ 11:00 AM

    This bug occurs also with a Proc object that returns a string.

    The gist-url with the patch was deleted, so I post an easy workaround for this bug. Simply set the content type yourself somewhere inside the macro, like:

    caches_action :index, :if => Proc.new { |c| result = c.cache_me?; c.headers["Content-Type"] = 'text/xml; charset=UTF-8' if result; result },

    :cache_path => Proc.new { |c| File.join('abc', c.some_method) }
    
    
  • Mislav

    Mislav February 26th, 2009 @ 01:04 PM

    Aw damn, I've been cleaning up my gists and deleted the patch because I thought it was applied. If anyone needs it back, shout now. I was pretty sure this was fixed soon after this was reported.

    Christoph, can you make a failing test for your case?

  • Christoph Petschnig

    Christoph Petschnig February 28th, 2009 @ 12:25 AM

    Ok, I made the failing tests.

    I choose to attach a whole rails project instead of a single file. Please look at docs/README for some explanation.

    I am not an experienced tests writer, yet it seems to me, that I found two other bugs while writing the tests. Please look at the comments in test/functional/xml_caching_controller_test.rb therefore.

    I would like to investigate that a little further, but I will be buzy for the next seven days.

  • Mislav

    Mislav March 10th, 2009 @ 11:05 PM

    • Tag changed from caches_action, format, patch to bug, caches_action, caching, format, patch

    Here's the revised patch with failing tests for both cases: string key or proc that returns a string.

  • Repository

    Repository March 11th, 2009 @ 12:07 AM

    • State changed from “new” to “resolved”

    (from [fa45540cdb30cee44983c9121e3ebfc317d21668]) Ensure correct content type is declared after cache hits on actions with string cache keys [#1585 state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages