James A. Rosen
James A. Rosen

Reputation: 65232

Why is Rails' asset cache not working for JS in the staging environment?

I have my CSS and JS set to cache in RAILS_ROOT/app/views/layouts/application.html.erb:

<%= stylesheet_link_tag 'reset', ...
                        'layout', 'colors', :cache => 'cache/all' %>
<%= javascript_include_tag 'jquery-1.3.2.min', ...
                           'application', :cache => 'cache/all' %>

If I turn on caching in my development environment, everything works as planned:

# in RAILS_ROOT/config/environments/development.rb:
config.action_controller.perform_caching = true

When I put the same line in staging, though, /stylesheets/cache/all.css is generated properly, but /javascripts/cache/all.css isn't. The line is generated in the HTML as though it were, though:

<script src="/javascripts/cache/all.js?1253556008" type="text/javascript"></script>

Going to that URL yields an empty JS file (though not a 404, oddly). There is no file on the file-system (under RAILS_ROOT/public/javascripts/cache/all.js).

Any thoughts?

Upvotes: 3

Views: 1429

Answers (1)

Matt Schwartz
Matt Schwartz

Reputation: 3394

It's a long shot but try deleting the all.js file and see if the app rebuilds it correctly. Once the file is in place Rails seems to never try to rebuild it, so if it was badly formed because of some bug or whatnot it may have been left there.

Upvotes: 3

Related Questions