Joomla static mirror

Kimo Johnson

11 August 2006

After spending time figuring out how to get the CS department web server to talk to my existing joomla database, I decided it was just too slow. Pages were taking between 3 and 5 seconds to load and I think most of the delay was from communication between the two servers. Even with caching enabled, it wasn't fast enough for me.

The solution was actually fairly simple, though it requires a little bit of work on my part each time I update the site. I found a nice utility called WebGrabber.app (HTTrack is another I looked into) that downloads an entire site, even dynamic database-driven sites, and rewrites all the links to be local links. Since my content changes infrequently, it isn’t a bad solution. It messed up a few of my links but it wasn’t anything that a few recursive find-and-replace commands couldn’t fix:

# find all html files below this directory, replace instances of "index.html" with "index.html"
# on OS X
find . -name "*.html" -type f -exec sed -i '' 's/index\.php/index\.html/g' {} \;
 
# on Fedora Core 4 Linux, remove the '' after -i
find . -name "*.html" -type f -exec sed -i 's/index\.php/index\.html/g' {} \; 
 
# list all files that contain "../../blog.html" (one of the invalid links)
grep -rl "\.\./html" .
 
# replace "../../blog.html" with "../../blog.html" (run on files in the blog directory)
find . -name "*.html" -type f -exec sed -i '' 's/\.\.\/html/..\/..\/blog.html/g' {} \; 
 
# replace "../../blog.html" with "../../publications.html" (run on files in the publications directory)
find . -name "*.html" -type f -exec sed -i '' 's/\.\.\/html/..\/..\/publications.html/g' {} \;

With those 3 fixes, the site seems to be working fine, and it’s much faster since all the pages are now static.