documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Repackaging on every request even though there are no changes #59

Closed tyen closed 14 years ago

tyen commented 14 years ago

I'm using jammit 0.5.1, and in development it is repackaging everything I've defined in assets.yml even though I make 0 changes in between requests. Right after line 121 in package.rb I put this debug statement

Rails.logger.info(cached.find { |file| !File.exists?(file) } )

In my ApplicationController I inserted the before_filter suggested

before_filter { Jammit.packager.precache_all } if Rails.env.development?

Here is what is printed out every single time I make a local request from my debug statement. Since it's detecting changes it repackages everything, making every page load take about 10 seconds.

public/assets/public-datauri.js
public/assets/private-datauri.js
public/assets/private_print-mhtml.css
public/assets/private_staging-mhtml.css
public/assets/public-mhtml.css
public/assets/private_development-mhtml.css
public/assets/private-mhtml.css
public/assets/public_print-mhtml.css

Jammit is not generating those missing files, but it is generating .js, .js.gz, .css, and .css.gz files into public/assets.

Here is my assets.yml

embed_assets: on
package_assets: always

stylesheets:
  # PRIVATE
  private:
    - public/stylesheets/*.css
  private_development:
    - public/stylesheets/environments/development.css
  private_staging:
    - public/stylesheets/environments/staging.css
  private_print:
    - public/stylesheets/print/print.css

  # PUBLIC
  public:
    - public/stylesheets/*.css
  public_print:
    - public/stylesheets/print.css

javascripts:
  # PRIVATE
  private:
    - public/javascripts/*.js

  # PUBLIC
  public:
    - public/javascripts/*.js

I stopped it from repackaging by turning embed_assets off. Should it be behaving this way? Thanks for reading

jashkenas commented 14 years ago

I'm a bit confused by what you're trying to accomplish with that configuration. I'd recommend running it with the default options:

embed_assets: on
package_assets: on

(or simply removing them from assets.yml)... and also removing your before_filter

In development, the assets will be included -- and in production, they'll be packaged if you haven't used the jammit utility to package them in advance. Make sense?