Project

General

Profile

Actions

CacheMetaLanguage » History » Revision 1

Revision 1/14 | Next »
jan, 2005-07-16 13:25
added examples for CML


= CML aka Cache Meta Language =

What Is It

CML tries to move the decision about a cache-hit and cache-miss for a dynamic website
out of the dynamic application, removing the need to start the application or dynamic
language at all.

Especially PHP is know to have a huge overhead before the script is started to be executed.

How To Install

The language used by CML is LUA which you can find at http://www.lua.org/

The get some background how to write LUA check out:

Benifits

The main benifit of CML is its performance.

A very simple benchmark showed:

  • about 1000 req/s for the static 'output.html' which is generated
  • about 600 req/s if index.cml is called (cache-hit)
  • about 50 req/s if index.php is called (cache-miss)

Using CML improves the performance for the tested page by a factor of 12, getting
near enough to the possible maximum of the static file transfer.

Usage Patterns

http://www.lighttpd.net/ is using CML to reduce the load (even if the load is minimal).

The layout of the front page depends on a few files:

  • content-1
  • content-6
  • the template /main.tmpl

If one of the files gets changed the cached version of the page has to be changed too.

{{{
#!ruby
output_contenttype = "text/html"

trigger_handler = "index.php"

-- this file updated by the trigger
output_include = { "output.html" }

docroot = request["DOCUMENT_ROOT"]
cwd = request["CWD"]

-- the dependencies
files = { cwd .. "content-1", cwd .. "content-6", docroot .. "main.tmpl" }

cached_mtime = file_mtime(cwd .. "output.html")

-- if one of the source files is newer than the generated files
-- call the trigger
for i,v in ipairs(files) do
if file_mtime(v) > cached_mtime then return 1 end
end

return 0
}}}

Updated by jan almost 19 years ago · 1 revisions