eZ Publish + lighttpd + static cache = success!

Author Message

Peter Putzer

Monday 27 August 2007 1:38:08 pm

If anyone else needs to set up eZ Publish with lighttpd and static cache, here's the configuration I'm using:

lighttpd.conf (snippet):

#
# Static cache (needs mod_magnet)
#
magnet.attract-physical-path-to = ( "/etc/lighttpd/static-cache.lua" )

static-cache.lua:

-- 
-- Static cache for eZ Publish
--

--
-- Requires Perl-comaptible regular expressions
--
require("rex_pcre")

uri_path = lighty.env["uri.path"]
static_cache_file = lighty.env["physical.doc-root"] .. "/static" .. uri_path .. "/index.html"

--
-- Do not rewrite some URLs
--
rewrite = 
        rex_pcre.match(uri_path, "\.(css|html?|pdf|js|png|gif|jpe?g|htc|jar|ico)$") == nil or 
        not(rex_pcre.match(uri_path, "^/content/download/.*$") == nil)
--
-- Never rewrite index.php
--
rewrite = rewrite and not(rex_pcre.match(uri_path, "^/index\.php"))

--
-- Some URLs can't be cached
--
cache = rewrite and (
                not(lighty.env["request.method"] == "POST") and
                lighty.env["uri.query"] == nil
                )

if cache then
        if not(nil == lighty.stat(static_cache_file)) then
                lighty.content = { { filename = static_cache_file } }
                lighty.header["Content-Type"] = "text/html"

                return 200
        else
                rewrite = true
        end
end

if (rewrite) then
        lighty.env["uri.path"] = "/index.php" .. lighty.env["uri.path"] 
        lighty.env["physical.rel-path"] = lighty.env["uri.path"]
        lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
end

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:29:49
Script start
Timing: Jan 31 2025 06:29:49
Module start 'layout'
Timing: Jan 31 2025 06:29:49
Module start 'content'
Timing: Jan 31 2025 06:29:49
Module end 'content'
Timing: Jan 31 2025 06:29:49
Script end

Main resources:

Total runtime0.0156 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 588.2891151.2266
Module start 'layout' 0.00470.0028 739.515636.6797
Module start 'content' 0.00750.0065 776.195390.2500
Module end 'content' 0.01390.0016 866.445329.9922
Script end 0.0155  896.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.1279140.0002
Check MTime0.00127.4907140.0001
Mysql Total
Database connection0.00063.858610.0006
Mysqli_queries0.002214.404430.0007
Looping result0.00000.108710.0000
Template Total0.00117.210.0011
Template load0.00095.623410.0009
Template processing0.00021.591810.0002
Override
Cache load0.00063.820410.0006
General
dbfile0.001811.793280.0002
String conversion0.00000.064340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs