A while back i noticed that my css changes were not taking effect on production (after running cap deploy). A quick check on my css inclusion method revealed the problem. I was using a single application.css file to import all css files through the use of import.
The reason for the stagnant styles? Well, my understanding is (feel free to correct me) the browser caches the static imports with a long expire time. So, following a deploy, several pages views will appear the same as before.
A next step i guess is caching the included stylesheets. This appears to be an upcomming feature of Rails 2.0.
<%= stylesheet_link_tag "application" %>
public/stylesheets/application.css
@import "base.css";
/* Defaults */
@import "grid.css";
@import "table.css";
@import "tabs.css";
.
.
etc
<%= render :partial => 'layouts/styles' %>
app/views/layouts/_styles.rhtml
<% Dir["public/stylesheets/*.css"].each do |style| %>
<%= stylesheet_link_tag File.basename(style) %>
<% end %>
There is 1 comment for this article
Comments are closed.
Matt Johnson
21 Aug 14:11