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.

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