Forums / Developer / Static Cache URLs Point to PHP site

Static Cache URLs Point to PHP site

Author Message

Russell Michell

Tuesday 29 April 2008 8:51:19 pm

Hi there folks,

I have been struggling with EZ's static cache for about a day now. I can get it to 'work' with cached folders and index.html files all generated into my 'static' directory. But all the links in the static version of the site point back to the dynamic (PHP) site (complete with 'index.php/eng'). How do I get them to reference other .html files also in the 'static' directory?

I have spent the afteroon searching the forum and reading all the online docs I could find (That's what EZ has btw, that Plone for example doesn't - *really* good docs~ :-), but still cannot find a fix. Can anyone help?

Messing with Apache rewrite rules *won't* work in my circumstance as the cached .html files will need to be copied to three separate webservers. For performance reasons we *don't* want any public access to the dynamic site. The dynamic PHP install and admin siteaccess remains behind our LAN to be used only by our company staff. When content updates are made, the cache will get regenerated locally (behind the LAN) via makestaticcache.php and then subsequently rsynced to our separate servers.

Here is my setup:
=================

It is a non Virtual Host setup, access is simply: mydomain.co.nz/ezpublish/index.php/mysiteaccess

- EZ 4.0
- PHP 5.2.5
- Apache 2.2.8
- MySQL 4.1
- Linux (FC5)
- Firefox 2.0.0.14

Cache is built thus:
====================

#> php ./bin/php/makestaticcache.php -f -s mysiteaccess

The 'static' directory is outside EZz's directory structure: /var/www/htdocs/cms-deploy/ezpublish/static/

Here are my ini settings:
=========================

settings/override/staticcache.ini.append.php

[CacheSettings]
HostName=mydomain.co.nz/ezpublish/index.php
StaticStorageDir=/var/www/htdocs/cms-deploy/ezpublish/static/
MaxCacheDepth=5

CachedURLArray[]=/Products
CachedURLArray[]=/Products*
CachedURLArray[]=/Solutions
CachedURLArray[]=/Solutions*
CachedURLArray[]=/Training
CachedURLArray[]=/Training*
CachedURLArray[]=/Support
CachedURLArray[]=/Support*
CachedURLArray[]=/Getting-started
CachedURLArray[]=/Getting-started*
CachedURLArray[]=/Company
CachedURLArray[]=/Company*

# A list of locations that will be updated whenever an object is published. You
# can NOT use a wildcard here.
AlwaysUpdateArray[]
AlwaysUpdateArray[]=/

settings/override/site.ini.append.php

...
[ContentSettings]
StaticCache=enabled
...

Thanks very much for your time :-)

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

André R.

Wednesday 30 April 2008 1:58:50 am

>How do I get them to reference other .html files also in the 'static' directory?

You don't, this is handled by the apache rewrite rules that check if a html file is present, if not the dynamic page is used.

Doc:
http://ez.no/download/ez_publish/changelogs/ez_publish_3_6/new_features/static_caching_of_content

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Russell Michell

Wednesday 30 April 2008 2:40:45 pm

Ah, thanks. Now I understand.

This does seem a little odd to me though. I appreciate what is trying to be done here (ie cache only those areas of the site that need to be, allowing still for some dynamic interaction) but this removes the possibility of being able to 'cache' the <i>entire</i> site.

Plone CMS has had this functionality for about 4 or 5 years and the new kid on the block, here in NZ at least is Silverstripe (www.silverstripe.com) which is having this functionality built into it as I write.

As you can see from my use-case above, I really need to be able to 'cache' ('cook') dynamic content into static HTML, CSS and images in order to deploy an entire site remotely.

I will try and modify the code to deal with the link issue and of course to grab the images. Otherwise I'll have to use a manual 'scrape' or try out another CMS.

The ability to 'cache' was one of the main things that brought me to eZ - but it doesn't seem to work in the same way one might expect it to.

Many thanks for your time.
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Russell Michell

Thursday 01 May 2008 7:54:13 pm

OK, for those who encounter this thread in the future, a much-much easier was a shell script. Just make sure you really need the --cut-dirs and --exclude-directories options.

Obviously more info can be had on your unix-like system by typing:

#> man wget

The script:

#!/bin/bash
#Shell script to deploy an eZ Publish website.
# Me, May 1, 2008

# The URL to fetch:
URL=$1
# The dir to pile everything into locally
DIR=$2

# An array of dirs to exclude:
EXC[0]=ezpublish/index.php/eng/Community
EXC[1]=ezpublish/index.php/eng/user

# Build a list of dirs to exclude:
for exclusion in "${EXC[@]}"
        do
        LIST+="$exclusion,"
done

# Remove the last comma: (Operator "%%" means "delete FROM the RIGHT, to the LAST case of what follows.")
LIST=${LIST%,*}

# The command:
CMD="wget -mErp"
CMD="$CMD -nH"
CMD="$CMD --convert-links"
CMD="$CMD --cut-dirs=2"
CMD="$CMD -P$DIR"
CMD="$CMD --exclude-directories=$LIST"
CMD="$CMD $URL"

# Execute
$CMD

Save the file as somethng like: ez-deploy.sh and chmod it such that your system user can execute it:

#> chmod u+x ez-deploy.sh

Invoked:

#> cd path/to/parent-of-ez-deploy.sh
./ez-deploy.sh http://site-todeploy.co.nz/ezpublish/ local-dir-to-download-into

NJoi :-)

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

eZ debug

Timing: Jan 20 2025 14:24:03
Script start
Timing: Jan 20 2025 14:24:03
Module start 'content'
Timing: Jan 20 2025 14:24:03
Module end 'content'
Timing: Jan 20 2025 14:24:03
Script end

Main resources:

Total runtime0.1561 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.9766180.8281
Module start 'content' 0.00690.0057 769.8047102.0078
Module end 'content' 0.01260.1434 871.8125533.2969
Script end 0.1561  1,405.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.3203200.0002
Check MTime0.00140.8957200.0001
Mysql Total
Database connection0.00080.529110.0008
Mysqli_queries0.107668.93851410.0008
Looping result0.00130.82631390.0000
Template Total0.143191.610.1431
Template load0.00100.618110.0010
Template processing0.142191.003210.1421
Override
Cache load0.00050.344510.0005
Sytem overhead
Fetch class attribute can translate value0.00090.597510.0009
XML
Image XML parsing0.00030.182510.0003
General
dbfile0.00774.9234200.0004
String conversion0.00000.002630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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