In Rails, how can I force update the client's js/css files?

When I use javascript_include_tag or stylesheet_link_tag to include files, they have a number at the end to make it easier to circumvent browser caching (update the file without changing the number, the browser still uses the cached version; change the number, the browser will download and use the updated file).

But where does this number come from? When is it updated? And how can I manually update it?

I'm still using Rails 2.3.9, but I guess answers for any version of Rails would be helpful since I couldn't find any.

Answers


Basically, in Rails 2, the number comes from the file's last modification date, and is added to the link as a query parameter. In Rails 3, it comes from a hash of the file's contents, and is added to the filename itself. The latter should be an improvement - see this page for more on the difference between the two.

Hope that helps!


Read http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html


Need Your Help

Generic templatized enum null value

c++ templates enums warnings clang

clang++ complains about a variable being uninitialized:

R knitr ordered list from dataframe

r knitr r-markdown

I'm trying to embed an R data.frame column as an ordered list in my knitr pdf output. So far my best atempt is: