Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question marks after images and js/css files in rails. Why?

Does anyone know why there are question marks (with a number) after the images and css files (when looking at the html code)? And how can I turn them off?

like image 910
spas Avatar asked Dec 05 '25 08:12

spas


2 Answers

From Rails API documentation:

By default, Rails will append all asset paths with that asset‘s timestamp. This allows you to set a cache-expiration date for the asset far into the future, but still be able to instantly invalidate it by simply updating the file (and hence updating the timestamp, which then updates the URL as the timestamp is part of that, which in turn busts the cache).

Hope it helps.

like image 190
Milan Novota Avatar answered Dec 06 '25 22:12

Milan Novota


It is to be able to cache the file on the client and still making sure the client receive the newest version when there is a change. So each file modification results in a new timestamp which the client will do a new request to the server to receive the modified file.

If you do not want to use (though I cannot see why - it is a good thing) simple do not use the rails helpers for including javascripts or stylesheets. Just include the normal HTML tags: link and script.

like image 33
Espen Avatar answered Dec 07 '25 00:12

Espen