(Config: Rails 2.3.2, Ruby 1.8.7, apache 2.2, assets are served from a
dedicated host specified in ActionController::Base.asset_host, in the
filesystem they are stored in a different folder than the RAILS_ROOT/
public folder.)
I face a problem with asset timestamps being changed for all my assets
when just one asset file has changed. Consequently it bursts the cache
of client browsers for all my assets, whereas I would like that only
the timestamp of the changed asset file be changed, so that others
assets are not bursted in the browser caches.
The scenario:
- I change one asset file on my dev machine.
- I deploy the new version of my app to my production server.
- A script automatically updates the assets which have changed, ie in
my assets folder only the asset file I changed initially has a changed
modification time.
- But when I reload a page of my app, I see in the page source code
that the timestamps automatically added by Rails to the asset files
are updated for all assets, not just for the changed asset
Is it the Rails expected behaviour? If so, is there a workaround to
have Rails change only the timestamp of the effectively changed asset
files? If there is no workaround, is there any other strategy to force
bursting cache of changed assets, whereas preserving the clients cache
of unchanged assets?
(Config: Rails 2.3.2, Ruby 1.8.7, apache 2.2, assets are served from a
dedicated host specified in ActionController::Base.asset_host, in the
filesystem they are stored in a different folder than the RAILS_ROOT/
public folder.)
I face a problem with asset timestamps being changed for all my assets
when just one asset file has changed. Consequently it bursts the cache
of client browsers for all my assets, whereas I would like that only
the timestamp of the changed asset file be changed, so that others
assets are not bursted in the browser caches.
The scenario:
- I change one asset file on my dev machine.
- I deploy the new version of my app to my production server.
- A script automatically updates the assets which have changed, ie in
my assets folder only the asset file I changed initially has a changed
modification time.
- But when I reload a page of my app, I see in the page source code
that the timestamps automatically added by Rails to the asset files
are updated for all assets, not just for the changed asset
Is it the Rails expected behaviour? If so, is there a workaround to
have Rails change only the timestamp of the effectively changed asset
files? If there is no workaround, is there any other strategy to force
bursting cache of changed assets, whereas preserving the clients cache
of unchanged assets?
Thanks by advance for your help
Regards,
Florent
OK, I've figured out the cause of my problem. Rails calculates the asset timestamps with the asset files contained in RAILS_ROOT/public. The mtime of those files are all changed when I deploy my application. To have Rails looks in my specific assets folders directory (different than RAILS_ROOT/public), I add a deploy task to symlink the RAILS_ROOT/public to this directory (I could not figure out how to set Rails.public_path in a config file).