I have deployed a Rails application on Heroku (web-server thin).
When I push it, I can see that the assets are properly precompiled
(Running: rake assets:precompile)
However, when I go to the my app site, and I browse between two pages with the same precompiled header
<head>
<-- ... other stuffs ... -->
<script src="/assets/application-5452d0cdbf85c04748c35fac325cd1d7.js" type="text/javascript"></script>
</head>
I can see (Chrome confirmed it [note: disable cache is set to :no on the developer tools] and Safari & Firefox same slowness) that the file is reloaded.
Heroku logs are confirming it
Heroku logs
2011-11-03T11:03:08+00:00 app[web.1]: cache: [GET /assets/application-5452d0cdbf85c04748c35fac325cd1d7.js?_=1320318188543] miss
From browsing on several website, it seems the for static content the setting need to be done at the level webserver, and on the ruby docs it is explained how to do for apache (http://guides.rubyonrails.org/caching_with_rails.html).
It’s the responsibility of the web server you use to set the far-future expiration date on cache assets that you need to take advantage of this feature.
Any experience with thin and how to configure the expiry on the js assets?
thanks
After two days of research, I found out what was wrong.
The "responsible" is jquery and the way it handle Ajax calls
Adding the following code fixed my issue
Then the browser is able to reload it properly (I can see in the developer tool for that specific javascript : Size (from cache) – Time: 11ms).
Furthermore, the way rails is signing the precompiled assets will allow me to have them properly reloaded if I’ll make a modification on the javascript (tested as well, the included in the header changed from
to
This is exactly the behaviour I was expecting and looking for.