I have a problem I was hoping someone could shed some light on. I noticed that with every request to my server, the css file was being requested. I went ahead and made a static link to the css file so there is no query string at all, but still I see the requests coming in with each request. Do I need to do anything else (in the response header maybe?) to make sure that browsers will cache the css? I am on Rails 2.0.2 Thanks, Tom --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Are you running in production mode? If so, then browsers should automatically cache the CSS file, afaik. Because of how the request to load a page works it might always include the CSS file. On Jan 22, 2008 7:40 AM, TomRossi7 <tom-5bxIUPmzHicFraO2wh7vUA@public.gmane.org> wrote:> > I have a problem I was hoping someone could shed some light on. I > noticed that with every request to my server, the css file was being > requested. I went ahead and made a static link to the css file so > there is no query string at all, but still I see the requests coming > in with each request. Do I need to do anything else (in the response > header maybe?) to make sure that browsers will cache the css? > > I am on Rails 2.0.2 > > Thanks, > Tom > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
I am running the server in production mode and the css is actually being rendered by a controller (e.g. /css/my_dynamic.css). I''ve noticed that each time the page is hit, I see a request for the CSS. On Jan 21, 5:40 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you running in production mode? If so, then browsers should > automatically cache the CSS file, afaik. > > Because of how the request to load a page works it might always include the > CSS file. > > On Jan 22, 2008 7:40 AM, TomRossi7 <t...-5bxIUPmzHicFraO2wh7vUA@public.gmane.org> wrote: > > > > > I have a problem I was hoping someone could shed some light on. I > > noticed that with every request to my server, the css file was being > > requested. I went ahead and made a static link to the css file so > > there is no query string at all, but still I see the requests coming > > in with each request. Do I need to do anything else (in the response > > header maybe?) to make sure that browsers will cache the css? > > > I am on Rails 2.0.2 > > > Thanks, > > Tom > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
If you''re dynamically creating the CSS file every time, it will be requested by the browser every time. This may probably because the modification date changes every time you generate the file. (I don''t really know--I''m just guessing.) Anyway, Ryan Bates has a screencast you should check out: http://railscasts.com/ In episode #88 he creates a dynamic Javascript file. In episode #89 he caches that javascript file. Sounds like that might be just what you''re looking for. On Jan 21, 5:57 pm, TomRossi7 <t...-5bxIUPmzHicFraO2wh7vUA@public.gmane.org> wrote:> I am running the server in production mode and the css is actually > being rendered by a controller (e.g. /css/my_dynamic.css). I''ve > noticed that each time the page is hit, I see a request for the CSS. > > On Jan 21, 5:40 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Are you running in production mode? If so, then browsers should > > automatically cache the CSS file, afaik. > > > Because of how the request to load a page works it might always include the > > CSS file. > > > On Jan 22, 2008 7:40 AM, TomRossi7 <t...-5bxIUPmzHicFraO2wh7vUA@public.gmane.org> wrote: > > > > I have a problem I was hoping someone could shed some light on. I > > > noticed that with every request to my server, the css file was being > > > requested. I went ahead and made a static link to the css file so > > > there is no query string at all, but still I see the requests coming > > > in with each request. Do I need to do anything else (in the response > > > header maybe?) to make sure that browsers will cache the css? > > > > I am on Rails 2.0.2 > > > > Thanks, > > > Tom > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
The timestamp query string is only created if you use the rails helper to link to the css. I went ahead and created a static link with no query string, but the browser still won''t cache it! I''m wondering if I need to set something in the response header to tell the browser to cache. Thanks for pointing out the screencast, I''ll definitely check them out but I would imagine he is talking about server-side caching... --Tom On Jan 21, 8:04 pm, partydrone <partydr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you''re dynamically creating the CSS file every time, it will be > requested by the browser every time. This may probably because the > modification date changes every time you generate the file. (I don''t > really know--I''m just guessing.) Anyway, Ryan Bates has a screencast > you should check out: > > http://railscasts.com/ > > In episode #88 he creates a dynamic Javascript file. In episode #89 he > caches that javascript file. Sounds like that might be just what > you''re looking for. > > On Jan 21, 5:57 pm, TomRossi7 <t...-5bxIUPmzHicFraO2wh7vUA@public.gmane.org> wrote: > > > I am running the server in production mode and the css is actually > > being rendered by a controller (e.g. /css/my_dynamic.css). I''ve > > noticed that each time the page is hit, I see a request for the CSS. > > > On Jan 21, 5:40 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Are you running in production mode? If so, then browsers should > > > automatically cache the CSS file, afaik. > > > > Because of how the request to load a page works it might always include the > > > CSS file. > > > > On Jan 22, 2008 7:40 AM, TomRossi7 <t...-5bxIUPmzHicFraO2wh7vUA@public.gmane.org> wrote: > > > > > I have a problem I was hoping someone could shed some light on. I > > > > noticed that with every request to my server, the css file was being > > > > requested. I went ahead and made a static link to the css file so > > > > there is no query string at all, but still I see the requests coming > > > > in with each request. Do I need to do anything else (in the response > > > > header maybe?) to make sure that browsers will cache the css? > > > > > I am on Rails 2.0.2 > > > > > Thanks, > > > > Tom > > > > -- > > > Ryan Bigghttp://www.frozenplague.net > > > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---