Serving static versions of dynamic pages (non-RoR)

Ian M. Evans ianevans at
Thu Aug 7 11:36:57 MSD 2008

As you might remember from the "fastcgi php migration" thread back in 
March, the list helped solve a problem migrating our apache setup where 
php ran through files with extensions (.php, .shtml) and extensionless 
files (e.g. /galleries/123/72 where galleries is a php script NOT a 
directory and /123/72 were the arguments or /some-event/day1/photos/12 
where photos was a php script that could be located in any depth of subdirs)

The solutions suggested by Igor and the list have worked perfectly. 
Thanks again!

I've been looking at various .conf's and have seen how they handle Rails 
static caching and I'm wondering how to apply that in my non-Rails setup.

Sometimes after a big event we can get hammered (once even getting 
listed on a Yahoo! news page) and I've thought about creating static 
versions of my script pages using php and curl or something.

I'd have two situations. One where an extensioned but argument-less php 
script had a cached .html version and second where an extensionless 
script and its pathinfo had a cached version

1) In the first case, say I had a database hungry file at:
/tribeca-fest/winners.shtml and I created a cached version as 
/tribeca-fest/winners.shtml.html am I correct in assuming that:

if (-f $request_filename.html) {

would serve it properly?

2) The 2nd case would be a little more crazy and I'm not sure if it's 

Let's say I have the extensionless file "galleries" in the root and it's 
pathinfo can be:
/galleries/123/     <- an overview listing
/galleries/123/5    <- a more detailed listing
/galleries/123/5/72 <- an individual photo

I could create three cache files:

Is there anyway for nginx to translate a request for /galleries/123/5/72 
or the other two examples into their underscore seperated .html equivalent?

I'm thinking that handling #1 is dead easy but the problem in #2 might 
be a little nuts? :-)

Thanks for any advice.

More information about the nginx mailing list