views:

141

answers:

3

I have read about a technique involving writing to disk a rendered dynamic page and using that when it exists using mod_rewrite. I was thinking about cleaning out the cached version every X minutes using a cron job.

I was wondering if this was a viable option or if there were better alternatives that I am not aware of.

(Note that I'm on a shared machine and mod_cache is not an option.)

A: 

You could use your cron job to run the scripts and redirect the output to a file.

If you had a php file index.php, all you would have to do is run

php index.php > (location of static file)

You just have to make sure that your script runs the same on command line as it does served by apache.

A: 

Does the page need to be junked every so often because it just has to? Or should it be paralleled with a static version after an update to the page?

If the latter, you could try and write a script that would make a copy of the just edited page and save it to its static filename version. That should lighten the write load since in that scenario you wouldn't need to have a fresh static copy unless there was a change made that needed some show time.

random
A: 

I would use a cache on application level. Because the application knows best when the cached version is out of date and is more flexible and powerful in the matter of cache negotiation.

Gumbo