sstephenson / sprockets

Rack-based asset packaging system
2.55k stars 24 forks source link

Sprockets Perma-Caching Files (Development) #169

Closed sgonyea closed 13 years ago

sgonyea commented 13 years ago

Sprockets seems to be permanently caching files, in development mode. Even if I re-save the actual file itself with changes, it continues to be served from the same cache. Restarting rails does not solve this issue, either.

To reproduce this specific problem, you can look at the toy project of mine:

https://github.com/sgonyea/todos-sproutcore20/tree/74eaecf925a5698fe34351a47c8d88f8b9d1ac44 (It's the todos app, using sproutcore 2.0 in Rails 3.1)

I experienced this issue while tweaking the HjsTemplate:

https://github.com/sgonyea/todos-sproutcore20/blob/74eaecf925a5698fe34351a47c8d88f8b9d1ac44/lib/hjs_template.rb

ie, modify the output from the evaluate method. Changes there do not reflect in the request, even after a restart of Rails. Changes are also not reflected when I modify the todos template itself:

https://github.com/sgonyea/todos-sproutcore20/blob/74eaecf925a5698fe34351a47c8d88f8b9d1ac44/app/assets/javascripts/templates/todos.js.hjs

In order to get changes in either place to show up, I basically have to delete the contents of tmp/cache/assets/*

josh commented 13 years ago

File caching is enabled in dev mode by default in Rails for speed. You're notice a bunch of random files under tmp/cache.

If you want to hack on a handler, I'd suggest disabling while you're doing so. Theres no way for sprockets to know you made changes to that file.

The other thing to do is bump your assets version by hand.

config.assets.version = '1.1'

This expires all your assets. You really want do to that if you update a handler and redeploy.

michaelirey commented 11 years ago

I actually found the cache directory had somehow been corrupted. An rm -rf tmp/cache/assets solved the problem.