Ideally it is up to the sitebuilder to implement a system of cache warming. In reality it will be only a minority that will do so.

As the Flickr module aims to make life easier for the sitebuilder we could offer this significant performance improvement out-of-the-box in a sub-module. It is then up to the sitebuilder to enable this or take care of it themselves.

Comments

lolandese’s picture

We could use something like:

  //Cache warming.
  // Return all nids of nodes not of type 'php'.
  $nids = db_select('node', 'n')
    ->fields('n', array('nid'))
    ->fields('n', array('type'))
    ->condition('n.type', 'php', '<>')
    ->execute()
    ->fetchCol(); // returns an indexed array
  // Now visit each node.
 global $base_url;
 foreach ($nids as $nid) {
    drupal_http_request($base_url . '/node/' . $nid);
  }

A test showed it works as expected. Maybe to extend with:

  • configuration to limit it to certain content types or access rules
  • run on cron (configurable as the block cache expiration)
  • screen and watchdog message on time-out and on which nodes it occurs
  • fallback to cURL if drupal_http_request() returns errors
  • adding a checkbox add the bottom of the config form to rebuild the cache of all content (can take a long time).

To take care of:
Make sure that if cron is not set it doesn't have the opposite effect, as in D7 cron runs then on first visitor after expiration.

lolandese’s picture

lolandese’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new7.35 KB

TODO:

  • screen and watchdog message on time-out and on which nodes it occurs
  • fallback to cURL if drupal_http_request() returns errors
  • handle cache warming in batch to avoid time-out
  • Detect if automatic running of Cron is disabled over at Administration » Configuration » System » Cron. If so give a recommendation to do so and why. See also http://colans.net/blog/improving-drupal-7-performance-after-period-inact....
  • test to run cron without cache warmer kicking in (interval not expired yet). If pages load slow we should recommend to change the Minimum cache lifetime at admin/config/development/performance to be the same as the Flickr Cache Warmer settings or maybe even use its value instead.
lolandese’s picture

StatusFileSize
new12.45 KB

NOTE: The Flickr Cache Warmer only seems to work well if you set the 'Minimum cache lifetime' to 'none'.

  • lolandese committed 81abacc on 7.x-1.x
    Issue #2422063 by lolandese: Built-in cache warmer
    
lolandese’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.