When a request comes in to dispatcher for a file (eg. image, html, js) how does it know if it is for a static file from the public folder or it is a request for a dynamic file generated by a controller? Some URLs: /images/logo.png /files/34 /files/34.pdf The first URL refers to a static file in /public/images The second URL refers to a dynamic file The third URL could refer to a static or dynamic file There are a few clues for dispatcher, first there is the URL itself, which in the case of static file always has a filename, but then a dynamic file can also optionally be in the filename form. Secondly there is the HTTP accept header which might text/javascript, but then you would expect this to be set correctly by the client (which does not know if a file is static or dynamic). Many thanks, K. -- 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 -~----------~----~----~----~------~----~------~--~---
Gareth Adams
2006-Aug-31 10:43 UTC
Re: How does Rails know a request is for a static (public) file?
kris <rails-mailing-list@...> writes:> > > When a request comes in to dispatcher for a file (eg. image, html, js) > how does it know if it is for a static file from the public folder or it > is a request for a dynamic file generated by a controller? >It''s actually the other way around. Apache looks for a file matching the request URL in the /public folder, and if it can''t find one it passes the entire request to dispach.(f)cgi or wherever to be handled by Rails. Look at the /public/.htaccess to see how it does that --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---