Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Sort cached files before generating manifest key #18

Merged
merged 1 commit into from

4 participants

@dsrw

My heroku app seems to be slurping up the file list in a different order on each dyno, producing a different manifest key for each process that's running my application. Sorting the files before generating the key fixes the problem.

@kristenhazard

Scott, thank you for this. I've been trying to understand why my application.manifest kept changing between initial download and checking on my heroku deployments. Saw your comment on rake-offline issues which lead me to this fix. Thank you thank you thank you.

@wycats wycats merged commit e87765e into from
@dustinsmith1024

I am having issues on Heroku with the digest key changing very often. Wondering if I am missing a setting or if something changed on Heroku maybe that someone else has run into. Thanks for the help.

Routes file:

  offline = Rack::Offline.configure do
    public_path = Pathname.new( Rails.public_path )

    # all files in public folder
    Dir["#{public_path.to_s}/**/*"].each do |file|
      cache Pathname.new(file).relative_path_from(public_path).to_s if File.file?(file)      
    end

    cache "/notes/rs"
    cache "/notes/fs"
    cache "/notes/t"
    cache "/notes/w"
    cache "/notes/s"
    cache "/races"
    cache "/races/new"
    network "*"
  end
  match "/application.appcache" => offline

Production.rb:

  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2012
  1. @dsrw

    Sort the files in the manifest before generating the key to ensure a …

    dsrw authored
    …consistent manifest across multiple processes.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/rack/offline.rb
View
2  lib/rack/offline.rb
@@ -72,7 +72,7 @@ def call(env)
private
def precache_key!
- hash = @config.cache.map do |item|
+ hash = @config.cache.sort!.map do |item|
path = @root.join(item)
Digest::SHA2.hexdigest(path.read) if ::File.file?(path)
end
Something went wrong with that request. Please try again.