# Javascript and caching

**URL:** <https://www.ruby-forum.com/t/javascript-and-caching/158785>\
**Category:** Rails\
**Created:** [January 27, 2009, 11:26pm UTC](https://www.ruby-forum.com/t/javascript-and-caching/158785 "2009-01-27T23:26:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 11:26pm UTC](https://www.ruby-forum.com/t/javascript-and-caching/158785/1 "2009-01-27T23:26:25Z")

</div>

Hi guys,

I’ll start to develop a new app that uses some heavy js librarys  
(prototype, scriptaculous, tinymce and so on).

Someone told me to make all the app using ajax, so all the js files  
will be loaded only once.

My question is, I really must do everything on ajax?

Lets say if I call [myapp.com/projects](http://myapp.com/projects) and projects use all those js  
files, then I click on a “show” link and I’m redirected to [myapp.com/](http://myapp.com/)  
projects/1 on this redirect, all js will be reloaded again?

Whats the best way to handle with javascript and caching?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 11:33pm UTC](https://www.ruby-forum.com/t/javascript-and-caching/158785/2 "2009-01-27T23:33:28Z")

</div>

On 27 Jan 2009, at 22:19, removed\_email\_address@domain.invalid wrote:

> My question is, I really must do everything on ajax?
> 
> Lets say if I call [应用宝官网-全网最新最热手机应用游戏下载](http://myapp.com/projects) and projects use all those js  
> files, then I click on a “show” link and I’m redirected to [myapp.com/](http://myapp.com/)  
> projects/1 on this redirect, all js will be reloaded again?

Not necessarily - if your web server is serving the JS files with the  
correct caching headers then the browser shouldn’t reload them (and  
using gzip encoding will make a big difference too).

Fred
