>Dear All,
>
>Does anybody have any solutions, which makes possible to produce static
>pages of all dynamic cms once a day and can be easily integrated into
>already made site?

Why do you need to do this? Is it because of hosting restrictions,
performance concerns, or portability/mirroring (which is a form of hoting
restriction I suppose)?

There are a number of ways to approach this problem...

If your sole concern is performance, judicious use of caching could be
your answer. You can cache your code using PHP Accelerator or Turck
MMCache, which helps with load times, or you can cache your data by
implementing a caching layer between your application and your database. I
believe PEAR has some classes designed for this. They basically all boil
down to memoizing function return values with the serialize/unserialize
functions, and storing those results in files. I have used this method in
applications to great effect - a cascading cache that stores database
results, page components like navigation areas, and entire pages is a
great performance enhancer, but you need to know how to mark and remove
stale data dynamically.

If you need a static version of your site due to hosting restrictions, you
can used a spider such as wget (I think has been mentioned in this thread)
to crawl your site and generate a local copy for you. Wget is an excellent
one, because it has options like --page-requisites and --convert-links
which make it easy to generate a self contained site mirror. This approach
requires that your dynamic links all have a slash-syntax, like
index.php/foo/bar/etc/. It's very easily implementable in a series of Make
rules - I use this method for www.stamen.com, where rolling out a new
version of the site is a simple matter of 'make clean; make live'.

You can also use the 'page fault' method, which is my personal favorite.
Let Apache's mod_rewrite handle your caching and URL-rewriting:
        1) user requests page foo/index.html
        2) if foo/index.html does not exist in filesystem, Apache knows to
           redirect this request to bar.php
        3) bar.php performs actions needed to generate contents of
           foo/index.html, and also creates the file
        4) bar.php returns contents of foo/index.html
        5) subsequent requests for foo/index.html just return that file,
           bypassing PHP entirely.
This one's sort of a balancing act though. It has been suggested here that
you can use Apache's ErrorDocument directive to direct the request to
bar.php, but this has the unfortunate side-effect of returning a 404
status code with the response. Not really a problem with a normal browser,
but when those responses are (for example) XML files used by flash, the
404 causes it to error out regardless of the content of the response. A
better method is to use a string of RewriteCond's, like so:
        RewriteCond     %{REQUEST_FILENAME}     !-f     [OR]
        RewriteCond     %{REQUEST_FILENAME}     -d
        RewriteCond     %{REQUEST_FILENAME}/index.html  !-f
        RewriteRule     ^.*$    bar.php
Obviously, this method is totally incompatible with any form of actual
dynamic content, but you're asking for ways to generate static output, so
I assume that's not an issue. The difficulty with this one is the same as
with any caching system as above - finding and flushing stale data. I do
this by rolling the cache deletion code into the editing functions, but
you can also use a cronjob to find and flush files older than some cutoff
time period.

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to