Laurie Young
Laurie Young

Reputation: 138444

Removing static file cachebusting in rails

I have a rails application which is still showing the cachebusting numeric string at the end of the URL for static mode, even though I have put it into the production environment. Can someone tell me what config option I need to set to prevent this behaviour...

Upvotes: 1

Views: 591

Answers (2)

Dave Cheney
Dave Cheney

Reputation: 5765

To disable the ?timestamp cache busting in production add this to your config/environments/production.rb

ENV['RAILS_ASSET_ID'] = ''

If you want to dig deeper into what this does, check out asset_tag_helper.rb in the ActionPack gem, line 527 (ish)

Upvotes: 2

emk
emk

Reputation: 60922

That file isn't there to break the cache during day-to-day operations. At least in theory, proxy servers are allowed to cache HTTP GET requests (as long the parameters remain the same).

Instead, that number is there to allow you to smoothly upgrade your CSS and JavaScript files from one version to the next. As I understand it, it's supposed to remain on in production mode. The numbers should only change when the timestamps on your files change.

Are you seeing common proxy servers that completely fail to cache any HTTP GET request with a single parameter?

Upvotes: 4

Related Questions