# Caching of javascript and stylesheets

**URL:** <https://www.ruby-forum.com/t/caching-of-javascript-and-stylesheets/61614>\
**Category:** Rails\
**Created:** [May 25, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/caching-of-javascript-and-stylesheets/61614 "2006-05-25T16:55:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 25, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/caching-of-javascript-and-stylesheets/61614/1 "2006-05-25T16:55:11Z")

</div>

Is there a standard way to make sure a client’s web browser pulls the  
latest version of your style sheet or javascript file instead of using a  
cached one? We are currently using a tedious way where we add a  
version number to the file (e.g. screen-v12.css) and when Rails boots up  
it finds the latest version in the style sheet folder. On the other  
hand, I have seen Basecamp append some kind of query string to the  
include href, e.g. href="/stylesheets/screen.css?1147466741". Not sure  
what their logic is for coming up with that query string parameter.

Anyway, it would be nice if there were some standard way to deal with  
this problem. Is there one? What are other people doing?

thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 25, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/caching-of-javascript-and-stylesheets/61614/2 "2006-05-25T17:07:12Z")

</div>

There a plugin called asset\_timestamping which will do what you want.  
Harvey

On 25/5/06 15:55, “Jeff C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> this problem. Is there one? What are other people doing?
> 
> thanks,  
> Jeff

This e-mail has been scanned for all viruses by MessageLabs.

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 25, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/caching-of-javascript-and-stylesheets/61614/3 "2006-05-25T17:24:59Z")

</div>

Harvey B. wrote:

> There a plugin called asset\_timestamping which will do what you want.  
> Harvey

Actually this asset timestamping ability is built into Rails now, since  
actionpack 1.12.1, I believe. Unfortunately, there’s not a very fine  
grain of control over it (it’s either on for everything, or nothing),  
but it’s there nonetheless.

Here is an excellent blog post on it:

[http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails](http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails)

- Danny

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [May 25, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/caching-of-javascript-and-stylesheets/61614/4 "2006-05-25T17:57:02Z")

</div>

Danny  
Thanks for the info  
Harvey

On 25/5/06 16:24, “Daniel B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Here is an excellent blog post on it:
> 
> [http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails](http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails)
> 
> - Danny

This e-mail has been scanned for all viruses by MessageLabs.
