Nicolas Blanco
2006-Sep-20 21:03 UTC
Newbie : What is the number Rails adds in images URL, etc?
If I write : <%= image_tag "rails.png" %> I get in HTML : <img alt="Rails" src="/images/rails.png?1158095722" /> What is the number at the end of the src tag ? What is it for ? Thanks :). Nicolas. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Caio Chassot
2006-Sep-20 21:15 UTC
Re: Newbie : What is the number Rails adds in images URL, etc?
On 2006-09-20, at 18:03 , Nicolas Blanco wrote:> <img alt="Rails" src="/images/rails.png?1158095722" /> > > What is the number at the end of the src tag ? What is it for ?That generates a unique url, forcing a refresh on every request. Especially useful for stylesheets. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jon Garvin
2006-Sep-20 21:16 UTC
Re: Newbie : What is the number Rails adds in images URL, etc?
A timestamp of when the file was last saved. It allows browsers to cache the file and not re-request it with every page load, while still knowing that they have the latest available version. Nicolas Blanco wrote:> If I write : > <%= image_tag "rails.png" %> > > I get in HTML : > <img alt="Rails" src="/images/rails.png?1158095722" /> > > What is the number at the end of the src tag ? What is it for ? > > Thanks :). > > Nicolas. > >--~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
David Coleman
2006-Sep-20 21:18 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Nicolas Blanco wrote:> What is the number at the end of the src tag ? What is it for ?http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails Check out the part about "on asset timestamping and Rails" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Nicolas Blanco
2006-Sep-20 21:33 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Interesting :)... Thank you all for your answers :). Nicolas. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
David Coleman
2006-Sep-20 21:37 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Caio Chassot wrote:> That generates a unique url, forcing a refresh on every request. > Especially useful for stylesheets.almost... "rails_asset_id checks the file’s modification timestamp and returns it to compute_public_path, which appends it as a query string." compute_public_path is called by tag(), which is called by image_tag(). So it only refreshes if the timestamp has changed. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jason Norris
2006-Sep-20 23:15 UTC
Re: Newbie : What is the number Rails adds in images URL, etc?
Ah! I was wondering the same thing myself. On 9/20/06, Caio Chassot <lists-eaoxph6vF1dWk0Htik3J/w@public.gmane.org> wrote:> > > > On 2006-09-20, at 18:03 , Nicolas Blanco wrote: > > > <img alt="Rails" src="/images/rails.png?1158095722" /> > > > > What is the number at the end of the src tag ? What is it for ? > > That generates a unique url, forcing a refresh on every request. > Especially useful for stylesheets. > >--~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Dion Hewson
2006-Sep-21 05:17 UTC
Re: Newbie : What is the number Rails adds in images URL, etc?
Caio and Jon''s answers seem to clash... who is right???? On 9/21/06, Jason Norris <jasonmnorris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Ah! I was wondering the same thing myself. > > On 9/20/06, Caio Chassot <lists-eaoxph6vF1dWk0Htik3J/w@public.gmane.org> wrote: > > > > > > > > On 2006-09-20, at 18:03 , Nicolas Blanco wrote: > > > > > <img alt="Rails" src="/images/rails.png?1158095722" /> > > > > > > What is the number at the end of the src tag ? What is it for ? > > > > That generates a unique url, forcing a refresh on every request. > > Especially useful for stylesheets. > > > > > > >-- www.blogsaic.com search, post, blog --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE
2006-Sep-21 05:59 UTC
Re: Newbie : What is the number Rails adds in images URL, et
David Coleman wrote:> Nicolas Blanco wrote: >> What is the number at the end of the src tag ? What is it for ? > > > http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails > Check out the part about "on asset timestamping and Rails"After reading that, it''s my understanding that the timestamp was introduced to force browsers to download updated assets instead of getting them from the cache. Seems like this behavior should be disabled in production mode. Joe -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Aaron Baldwin
2006-Sep-21 06:04 UTC
Re: Newbie : What is the number Rails adds in images URL, etc?
Jon is right from asset_tag_helper.rb: def rails_asset_id(source) ENV["RAILS_ASSET_ID"] || File.mtime("#{RAILS_ROOT}/public/#{source}").to_i.to_s rescue "" end File.mtime returns the modification time of the file which is appended to the asset. When the asset is modified the file name changes forcing browsers to pull the updated version. Aaron On Sep 20, 2006, at 11:17 PM, Dion Hewson wrote:> Caio and Jon''s answers seem to clash... > > who is right???? > > On 9/21/06, Jason Norris <jasonmnorris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > Ah! I was wondering the same thing myself. > > > On 9/20/06, Caio Chassot <lists-eaoxph6vF1dWk0Htik3J/w@public.gmane.org > wrote: > > > On 2006-09-20, at 18:03 , Nicolas Blanco wrote: > > > <img alt="Rails" src="/images/rails.png?1158095722" /> > > > > What is the number at the end of the src tag ? What is it for ? > > That generates a unique url, forcing a refresh on every request. > Especially useful for stylesheets. > > > > > > > -- > > www.blogsaic.com > search, post, blog > >--~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Why would you want to disable this? Assets change, even in production mode. A designer wants to push a margin a bit to the left or right, a new image replaces an existing one... The point is that this tagging forces the browser to pull down the new asset iff the modtime of the asset is different from the one currently in the browser cache. Cayce Balara-2 wrote:> > > David Coleman wrote: >> Nicolas Blanco wrote: >>> What is the number at the end of the src tag ? What is it for ? >> >> >> http://hypsometry.com/blog/on-browser-caching-asset-timestamping-and-rails >> Check out the part about "on asset timestamping and Rails" > > After reading that, it''s my understanding that the timestamp was > introduced to force browsers to download updated assets instead of > getting them from the cache. Seems like this behavior should be disabled > in production mode. > > Joe > > -- > Posted via http://www.ruby-forum.com/. > > > > >-- View this message in context: http://www.nabble.com/Newbie-%3A-What-is-the-number-Rails-adds-in-images-URL%2C-etc--tf2308121.html#a6422152 Sent from the RubyOnRails Users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Caio Chassot
2006-Sep-21 06:15 UTC
Re: Newbie : What is the number Rails adds in images URL, etc?
On 2006-09-21, at 02:17 , Dion Hewson wrote:> Caio and Jon''s answers seem to clash... > > who is right???? >Jon. but my justification is correct, the purpose is to force a reload. Rails is clever enough to use a timestamp so as to only force reloads when it really matters. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Aaron Baldwin
2006-Sep-21 06:18 UTC
Re: Newbie : What is the number Rails adds in images URL, et
On Sep 20, 2006, at 11:59 PM, Joe Ruby MUDCRAP-CE wrote:>> >> http://hypsometry.com/blog/on-browser-caching-asset-timestamping- >> and-rails >> Check out the part about "on asset timestamping and Rails" > > After reading that, it''s my understanding that the timestamp was > introduced to force browsers to download updated assets instead of > getting them from the cache. Seems like this behavior should be > disabled > in production mode.I don''t agree. If a file has not been updated then the only cost is the time it takes to check the modification date of the file. When you do update files in production the attached timestamp forces browsers to pull the most recent version, which is a good thing. I''ve seen plenty of cases where a browser continues to use a cached CSS file after its been updated on the server. Aaron --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE
2006-Sep-21 06:20 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Steve Ross wrote:> Why would you want to disable this? Assets change, even in production > mode. A > designer wants to push a margin a bit to the left or right, a new image > replaces an existing one... The point is that this tagging forces the > browser to pull down the new asset iff the modtime of the asset is > different > from the one currently in the browser cache.Cuz the URLs are yucky. My assets hardly change in production -- so infrequently that they''re probably already gone from any repeat visitor''s browser cache. Joe -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE
2006-Sep-21 06:33 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Aaron Baldwin wrote:> On Sep 20, 2006, at 11:59 PM, Joe Ruby MUDCRAP-CE wrote: >>> >>> http://hypsometry.com/blog/on-browser-caching-asset-timestamping- >>> and-rails >>> Check out the part about "on asset timestamping and Rails" >> >> After reading that, it''s my understanding that the timestamp was >> introduced to force browsers to download updated assets instead of >> getting them from the cache. Seems like this behavior should be >> disabled >> in production mode. > > I don''t agree. If a file has not been updated then the only cost is > the time it takes to check the modification date of the file. When > you do update files in production the attached timestamp forces > browsers to pull the most recent version, which is a good thing. > > I''ve seen plenty of cases where a browser continues to use a cached > CSS file after its been updated on the server. > > AaronI don''t understand why people are doing all this updating in production -- that''s just bad practice. Also, web servers ALSO check file modification times so they can send if/modified-since headers (not that I expect that cost to be of any significance). Joe -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Lionel Bouton
2006-Sep-21 07:59 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Joe Ruby MUDCRAP-CE wrote the following on 21.09.2006 08:33 :> [...] > I don''t understand why people are doing all this updating in production > -- that''s just bad practice.Ok, but... This helps when you upgrade the production with a new release. The problem is not the update frequency but only the fact that updates happen. Lionel. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Joe Ruby MUDCRAP-CE
2006-Sep-21 08:07 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Lionel Bouton wrote:> Joe Ruby MUDCRAP-CE wrote the following on 21.09.2006 08:33 : >> [...] >> I don''t understand why people are doing all this updating in production >> -- that''s just bad practice. > > Ok, but... > This helps when you upgrade the production with a new release. The > problem is not the update frequency but only the fact that updates > happen.Sure, but how bad is the browser caching problem? It seems like it usually takes (me) not more than a couple of reloads to grab the latest version from the server. Joe -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Mohit Sindhwani
2006-Sep-21 08:45 UTC
Re: Newbie : What is the number Rails adds in images URL, et
Joe Ruby MUDCRAP-CE wrote:> Lionel Bouton wrote: > >> Joe Ruby MUDCRAP-CE wrote the following on 21.09.2006 08:33 : >> >>> [...] >>> I don''t understand why people are doing all this updating in production >>> -- that''s just bad practice. >>> >> Ok, but... >> This helps when you upgrade the production with a new release. The >> problem is not the update frequency but only the fact that updates >> happen. >> > > Sure, but how bad is the browser caching problem? It seems like it > usually takes (me) not more than a couple of reloads to grab the latest > version from the server. > > Joe > >On the other hand, how bad is the ''bad URL'' problem? It should be fine if the URL is a bit dirty since Rails creates it itself.. and the problem is not a user like YOU who does the refresh. It is users who don''t know that they could/ should. Rails ensures that loading updated resources is the responsibility of the browser. But, it seems we may end up disagreeing on this issue :) Cheers Mohit. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---