CGI performance: using mod_cache
Andre Garzia
andre at andregarzia.com
Sat May 31 18:24:58 EDT 2008
David,
I am assuming you have a way to tell if the database changed since you
last poked into it.
Make your cgi generate static pages, this way, and trigger the
regeneration of the pages to new data being inserted onto the
database, this is quick and easy, everytime you enter new data, the
page is generated again.
Most browsers will send some information on the http headers such as
"ETag" or "if-modified-since", meaning, they are checking to see if
the content changed since they last looked into it, you can answer
with a "304 not modified".
If you combine both approaches, you save both your CPU cycles (not
querying the database all the time) and bandwidth (not transfering
webpages that are cached and did not change).
Andre
On Sat, May 31, 2008 at 1:29 AM, David Bovill <david at openpartnership.net> wrote:
> I'd like to speed up performance of a Rev based CGI by caching the results
> on the server - however I want to retain the CGI based dynamic behaviour.
> >From reading around it looks like this is possible, and I think this could
> be a generally useful hack for Rev based CGI's. AFAIK this is a fairly
> standard issue largely solved by other frameworks.
>
> Here is the scenario:
>
> 1. You have a dynamic cgi that fetches data from a database, munges these
> up and serves up your page
> 2. The CGI is painfully slow
> 3. It is not possible to optimise the cgi
> 4. You decide to use caching
> 5. But when you update the database you want to the new data to be served
> - you want to retain the dynamic behavior
> 6. Users need to be able to update the database - so you cant do this
> with your own code - you need an automatic solution.
>
> I am not sure how to achieve this - but there seem to be the server based
> functionality needed with any new Apache installation. Here are some
> "ideas":
>
> - The Rev CGI could set HTTP headers depending on if the data in the
> database had changed (not sure this will work)
> - The Rev CGI used to update the data (model)
> - also changes the .htaccess directive
> - somehow updates the cache
> - Give up using Apache Cache and simply write the data out to a file -
> creating and maintaining your own cache
>
> What you want is a robust file based "data_changed" flag - which instructs
> Apache to go fetch new data from the cgi.
>
> It seems that by using simply and carefully the built in Apache Cache
> ability - you should be able to use Revs flexible nature to create complex
> CGI's and not worry too much about optimising them or having to write extra
> code to store and maintain you own files. Any ideas?
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
--
http://www.andregarzia.com All We Do Is Code.
More information about the use-livecode
mailing list