Serving static versions of dynamic pages (non-RoR)

Ian M. Evans ianevans at digitalhit.com
Sat Aug 9 18:34:07 MSD 2008


Jean-Philippe Moal wrote:
> Otherwise you could still create your cache files using the same layout 
> as your URLs (by creating multiples directories and subdirectories).

Ah, I had an brief inkling of that thought last night.

So I'd have my PHP cache code create different dirs and index files so 
you'd have

/galleries/1  => /galleries/1/index.html
/galleries/1/27  => /galleries/1/27/index.html
/galleries/1/27/8  => /galleries/1/27/8/index.html

Since /galleries is actually a FILE in the root, not a directory, could 
I create a cache dir with a galleries dir elsewhere and say something 
like this:

if (-f /cache/$request_filename/index.html)
     {
       rewrite ^(.*)$ /cache/$1/index.html break;
     }

[No idea if that's the right way to do the syntax]

Also...is there any magic I'd need to do if someone added a trailing 
slash so the "if" wouldn't be looking for:
/galleries/1/27/  => /galleries/1/27//index.html
                                     ^^

Thanks for helping me think this through!





More information about the nginx mailing list