On Mon, Jun 09, 2003 at 01:20:47PM +1000, James Gifford wrote:
> I noticed there is some page caching functionality in Midgard. I found in
> the file /etc/apache/midgard-data.conf the following:
>
> MidgardPageCacheDir /var/www/midgard/page_cache
The page cache is something mod_midgard-preparser uses. If you use
mod_midgard-preparser *instead of* mod_midgard, midgard pages will be
assembled and written to the page cache dir before being executed; if
you're calling the same page more than once (which is pretty typical),
Midgard will use the pre-assembled ('cached') page instead of rebuilding
it for every request. Mod_midgard-preparser is compatible with APC
(http://apc.communityconnect.com/), which should yield another
performance boost, but I have not benchmarked it.
> ## Uncomment this if you want serve files instead of Midgard URLs
> ## where there's a match for both. You'd want to use this if you have
> ## active pages and you're using static dummy pages to force this
> ## behaviour. Note that this setting is apache-wide, not per-host.
> # MidgardFavorFiles On
>
> I don't understand what this means. If you turn it on, does it cache
> pages into that file and serve them from there? How do they get
> refreshed?
MidgardFavorFiles has no relationship with caching.
Mod_midgard-preparser relies on timestamps recorded at every object
additions/change/deletion that affects page building (article[0], element,
host, language[0], page, pageelement, sitegroup, style). When the cached
file is older than the timestamp, it is rebuilt.
Regarding FavorFiles, suppose you have a active page called /article
which you use to publish pages like /article/231.html, but you also
have /article/images in your documentroot. In the default setup,
/article/images/* would never be served from the filesystem, because
Midgard decides it's authoritive for /article/*, but then later decides
there's no /article/images, and returns 404 (or whatever). With
FavorFiles on, Midgard first checks to see if there's a file that will
satisfy the request and if so just has that file served before seeing if
it wants to be authoritive for the request. As Midgard does more work
here, you'll suffer a slight performance penalty for enabling this. I
haven't benchmarked this either.
> Most of our hits are to our front page. I was thinking of making it a
> published static page because it is quite complex and does a lot of calls
> to the database. Could I use this function to write the contents of the
> front page to a static file which gets refreshed whenever the content of
> the front page gets changed?
The cached pages as served by Midgard cache PHP code, not HTML. So the
page would still be re-executed by PHP, just not reassembled. FavorFiles
doesn't work for the root page, BTW, for which Midgard will always claim
ownership when you have an empty prefix in your host record.
> Many of our pages won't change very often but will be constructed using
> many database calls. Has anyone used an external caching engine with
> Midgard? What about Squid? Is it easy to specify what pages get cached
> and what don't and is it easy to refresh the cache, both manually and by
> cron job?
Yes, you can set up squid as an http accelerator in front of Midgard.
You'll have to emit the proper headers (for which you'll have to read
the Squid manual, I haven't used squid in a long time) to govern how
long Squid will cache each URL. So yes, it's easy, but it can be a
chore. Midgard has no way to know when you want some URL to expire (it
has no knowledge of what objects are used in page assembly and at what
point in the future these will expire/change), so you'll have to code
that into your Midgard page logic, which in turn may or may not be hard.
Context dependent. Note that you'll lose the ability to serve
personalised pages.
> Finally, I wanted to ask about MySQL caching. I looked up the MySQL
> manual for version 4.0.1 at
> http://www.mysql.com/doc/en/Query_Cache_How.html
> Has anyone looked at how well this works with Midgard? Can we assume if
> have this version of MySQL installed that this is all taken care of and
> MySQL is quietly caching away? Are there any issues with this version of
> MySQL and Midgard since it is kind of new?
Haven't tried.
Emile
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]