Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
Standup 04/30/2009: perform_caching and Rails.cache, W3C DTDs and IE, Range#min/max

Help

  • Perform_caching is not respected by Rails.cache methods.
    config.action_controller.perform_caching does not appear to affect the Rails.cache methods.
    Rails 2.1 introduced a new custom caching mechanism:
result = Rails.cache.fetch('key') do
  # create and return item for this key
end

It would be really nice if, for testing, you could set a configuration variable that would force a cache miss every time and always execute the block associated with the fetch. However it appears that, understandably, action_controller.perform_caching only affects the kinds of caching implemented by ActionController (page, action, fragment) and not this caching mechanism that is implemented by ActiveSupport::Cache::Store. Looking at the code, is appears there is no way to disable this caching mechanism other than supplying :force => true to the fetch call to force a cache miss.

  • W3C refusing to serve DTDs to ‘misbehaving’ clients.
    One of our applications that has not been deployed for a while is starting to see issues from IE users. After digging, we found this: W3C’s Excessive DTD Traffic and this w3.org DTD/xhtml1-strict.dtd blocks Windows IE users?. To summarize, w3.org got tired of getting slammed with non-cached DTD requests, and cut off misbehaving user agents (ones that do not cache the DTD). IE is one of these.

We have several things so far, none of which work:

  1. Forcing xhtml DTD to be a SYSTEM dtd, and load the DTD files off the local server. This didn’t work – IE serve the pages as raw unrendered html (must
    have thought it was XML?)

  2. Use a PUBLIC doctype pointing to the DTD served on our server. Alas, this had the same problem as the SYSTEM doctype in #1 – raw unrendered HTML.

  3. Not using XHTML (e.g. have as root tag). This didn’t work (haven’t
    looked into why yet).

Ideas are welcome.

Interesting

  • Range#min, Range#max: Don’t use them. Use Range#first and Range#last. Min and max are not overridden by Range so fall back onto Enumerable which then converts the Range into an Array first!

Comments
  1. Terjin says:

    Do you have this XML declaration on the top of your page?

    < ?xml version="1.0" encoding="UTF-8"?>

    Try removing that. That forces IE into quirks mode which uses a broken box model implementation. This could be the problem if you are using that tag.

  2. Cyril David says:

    What I do to force a cache miss for tests is I assign a different cache store for the test environment.

    Specifically in my config/environments/test.rb I do

    config.cache_store = BlackHoleStore.new

    the black hole store is something I just created, I pasted it here

    http://gist.github.com/104946

    Hope this helps.

  3. Chad Woolley says:

    @Terjin

    Yes, I tried removing the xml element – this was essentially option #3, not using XHTML. This is as simple as using the Markaby “html” method instead of “xhtml”. Unfortunately, this completely broke some of the offline Google Gears pages, and I didn’t investigate whether this was an issue with the page, or with Gears itself (other pages worked fine as non-xhtml).

    — Chad

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *