Jump to content

LazyCron: simple crawler/cache preloader

Recommended Posts

Hi guys,

this just came into my mind if you have MarkUpCache / TemplateCache enabled.

Is there a more elegant way than using a http request?

in site/ready.php:

<?php namespace ProcessWire;

function PreLoadCache(HookEvent $e) {
    $all = wire()->pages->find("has_parent!=2|1139|1029"); // no admin pages, contact forms, page tables
    $s=0; $f=0; $fn = '';
    $http = new WireHttp();

    foreach($all as $a) {
        $response = $http->get($a->httpUrl);
        if($response !== false) {
        } else {
            $fn .= $a->title . ", ";

    wire()->log()->save('croncaching', 'Cached: '. $s .' Pages, Failed at '. $f .' Pages: '. $fn .'');

wire()->addHook('LazyCron::every12Hours', null, 'PreLoadCache');


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...