How does Rails know a request is for a static (public) file?

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.

kris <[email protected]…> 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