pre-cache smarty site using wget
| From: | Daniel Cummings | Date: | Thu, 15 Apr 2004 20:39:56 +0000 |
| Subject: | pre-cache smarty site using wget | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11279@lists.php.net to get a copy of this message | ||
Hi,
Wahoo!
I just figured out how to get wget to crawl my smartified site and cause
caches to be created.
I need to pre-cache smarty pages because I want the optimum speed for
everyone; I don't want *anyone* to have to wait for database accesses. Also,
my site is quite static and my caches only expire when I expire them.
Here's how to do it using wget called from a php page. I installed wget
using fink (Mac OSX), but you may have another way.
<?php
// must have wget somewhere, change the path to it here
$wget_command = "/sw/bin/wget \"http://domain.com\" -r -q --delete-after";
// run wget script so it doesn't hang php (from php.net exec())
// start the wget process in the background
// the echo $! returns the PID
$pid = exec($wget_command . ' > /dev/null 2>&1 & echo $!');
print_r($pid);
?>
I also posted this information to the cache/compile wiki page.
http://smarty.incutio.com/?page=CacheAndCompile
Good luck,
dan