javascript_include_tag and stylesheet_link_tag additional generated parameters

222 views
Skip to first unread message

P.A.

unread,
Jun 10, 2010, 10:00:38 AM6/10/10
to Ruby on Rails: Talk
Hi.

I just wonder why do the javascript_include_tag and
stylesheet_link_tag methods generate additional parameters and add
them to the paths on output?

For example, I have the following view:

# app/views/test.haml

%html
%head
= stylesheet_link_tag 'styles.css'
= javascript_include_tag 'scripts.js'
...

and when I load it, I get the next HTML:

<html>
<head>
<link href="/stylesheets/styles.css?1276104169" media="screen"
rel="stylesheet" type="text/css" />
<script src="/javascripts/prototype.js?1275579095" type="text/
javascript"></script>
...

What do '1276104169' and '1275579095' mean and why are they added to
the paths?

Any help and links are wellcome.

Thanks.

Debian GNU/Linux 5.0.4;
Ruby 1.9.2;
Rails 2.3.8.

Frederick Cheung

unread,
Jun 10, 2010, 11:09:54 AM6/10/10
to Ruby on Rails: Talk


On Jun 10, 3:00 pm, "P.A." <shama...@hotmail.com> wrote:

>
> <html>
>   <head>
>     <link href="/stylesheets/styles.css?1276104169" media="screen"
> rel="stylesheet" type="text/css" />
>     <script src="/javascripts/prototype.js?1275579095" type="text/
> javascript"></script>
> ...
>
> What do '1276104169' and '1275579095' mean and why are they added to
> the paths?

They're the timestamps of when the file was changed. If you do update
the css/javascript files then when you next rollout the timestamp will
be different and people's browsers won't cache the old version

Fred

Rem Zolotykh

unread,
Jun 10, 2010, 7:01:22 PM6/10/10
to rubyonra...@googlegroups.com
And if you want to get rid of them for some reason just create new
initializer with following code:

ENV['RAILS_ASSET_ID'] = ''

and restart your server. All this numbers will go away.

> --
> You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-
> ta...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
> .
>

Reply all
Reply to author
Forward
0 new messages