Forums / Install & configuration / eZ Publish + lighttpd + static cache = success!

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

eZ debug

Timing: Jan 18 2025 19:05:49
Script start
Timing: Jan 18 2025 19:05:49
Module start 'content'
Timing: Jan 18 2025 19:05:49
Module end 'content'
Timing: Jan 18 2025 19:05:49
Script end

Main resources:

Total runtime0.0170 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.8672180.8047
Module start 'content' 0.00600.0066 768.671993.9922
Module end 'content' 0.01270.0043 862.664170.7031
Script end 0.0169  933.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002514.6108120.0002
Check MTime0.00116.5462120.0001
Mysql Total
Database connection0.00073.834610.0007
Mysqli_queries0.002514.853340.0006
Looping result0.00000.088320.0000
Template Total0.003822.610.0038
Template load0.00095.517110.0009
Template processing0.002917.025110.0029
Override
Cache load0.00074.004310.0007
General
dbfile0.00031.9503100.0000
String conversion0.00000.029430.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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