1

What would be the best way to have a html5 cache manifest with the rails asset pipeline? I'm thinking of adding an erb file to app/assets that has the paths of all the assets contained in it. This would work but has a couple problems right off the bat:

  • How could I increment the version number?
  • How can I make sure the http content type is set correctly?
Jeff Dickey
  • 5,036
  • 4
  • 28
  • 39

2 Answers2

1

Here's how we're doing it on an app right now:

  • To handle the generation of the cache manifest file, we are using Rack::Offline
  • We then configure this to point to, for instance, "/assets/application.css"
  • In the layouts/views, we are NOT using the stylesheet_link_tag, javascript_include_tag or image_tag helpers for cache-able assets so that we don't get a link to the assets with the hash in it, eg "/assets/application-2345234...2344.css"

This works because when the assets are precompiled, rake assets:precompile:nondigest creates versions of the files without the hash in the name, and then Rack::Offline checks these to generate a new manifest (or not).

Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297
Marc
  • 129
  • 6
  • 1
    I've also used this approach and it works for now. But this is certainly not a solution I'd like to keep over longer period time. It's more a hack than a proper way to do it :) I've been looking for a solution to get rack-offline and assets pipeline work nice together but have not yet found a way. Anyone else got rack-offline and rails' 3.1 assets pipeline working nice together? – Lenart Jan 16 '12 at 14:21
  • 2
    Couldn't you get around the third point by setting `config.assets.digest = false` in `production.rb`? – dazonic Jan 18 '12 at 07:30
-4

Sprockets provides you with one by default.

in one of your environment configs (/config/environments/development.rb)

config.assets.compress = false
config.assets.debug = false

and in your html file:

<html manifest="manifest.yml">

running

rake:precompile 

will give you a manifest file to public/assets/manifest.yml

shanejonas
  • 159
  • 1
  • 6