wycats / rack-offline

A Rack and Rails plugin for building offline web applications
MIT License
666 stars 82 forks source link

avoid caching old assets preserved by sprockets #31

Open ashanbrown opened 10 years ago

ashanbrown commented 10 years ago

Because sprockets by default leaves around the 2 previous copies of any assets, the default behavior of rack-offline.rb for rails is to cache three times the necessary data. This code picks only the latest file (based on ctime) and adds that to the manifest. Wasn't sure if this warranted testing since there is no corresponding test for rack-offline.

ashanbrown commented 10 years ago

Just a note about this: I've found that I have to sort by mtime to get the latest assets on heroku, even though sprockets picks the previous assets to keep based on ctime. This seems to happen because heroku appears to retain more than 3 copies of an asset for some reason, and manages to update the ctime of those stale assets to boot (all on rails4, fwiw).