Skip to content

Commit

Permalink
Document a few things that Phusion Passenger does under the hood.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed May 13, 2009
1 parent 5c7e51a commit 00ab178
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions doc/Users guide Apache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,55 @@ try drogus's link:http://github.com/drogus/apache-upload-progress-module/tree/ma
Apache upload progress module] instead.


== Under the hood ==
Phusion Passenger hides a lot of complexity for the end user (i.e. the web server
system administrator), but sometimes it is desirable to know what is going on.
This section describes a few things that Phusion Passenger does under the hood.

=== Static assets serving ===
Phusion Passenger accelerates serving of static files. This means that, if an URI
maps to a file that exists, then Phusion Passenger will let Apache serve that file
directly, without hitting the web application.

Phusion Passenger does all this without the need for any mod_rewrite rules. People
who are switching from an old Mongrel-based setup might have mod_rewrite rules such
as these:

------------------------------------------------------------
# Check whether this request has a corresponding file; if that
# exists, let Apache serve it, otherwise forward the request to
# Mongrel.
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ balancer://mongrel%{REQUEST_URI} [P,QSA,L]
------------------------------------------------------------

These kind of mod_rewrite rules are no longer required, and you can safely remove
them.

=== Page caching support ===
For each HTTP request, Phusion Passenger will automatically look for a corresponding
page cache file, and serve that if it exists. It does this by appending ".html" to
the filename that the URI normally maps to, and checking whether that file exists.
This check occurs after checking whether the original mapped filename exists (as part
of static asset serving). All this is done without the need for special mod_rewrite
rules.

For example, suppose that the browser requests '/foo/bar'.

1. Phusion Passenger will first check whether this URI maps to a static file, i.e.
whether the file 'foo/bar' exists in the web application's 'public' directory.
If it does then Phusion Passenger will serve this file through Apache immediately.
2. If that doesn't exist, then Phusion Passenger will check whether the file
'foo/bar.html' exists. If it does then Phusion Passenger will serve this file
through Apache immediately.
3. If 'foo/bar.html' doesn't exist either, then Phusion Passenger will forward the
request to the underlying web application.

Note that Phusion Passenger's page caching support doesn't work if your web
application uses a non-standard page cache directory, i.e. if it doesn't cache to
the 'public' directory. In that case you'll need to use mod_rewrite to serve such
page cache files.

include::users_guide_snippets/appendix_a_about.txt[]

include::users_guide_snippets/appendix_b_terminology.txt[]
Expand Down

0 comments on commit 00ab178

Please sign in to comment.