function boost_is_cacheable

cis7 boost.module boost_is_cacheable($parts, $request_type = 'normal')
cle7 boost.module boost_is_cacheable($parts, $request_type = 'normal')
elmsmedia7 boost.module boost_is_cacheable($parts, $request_type = 'normal')
icor7 boost.module boost_is_cacheable($parts, $request_type = 'normal')
meedjum_blog7 boost.module boost_is_cacheable($parts, $request_type = 'normal')
mooc7 boost.module boost_is_cacheable($parts, $request_type = 'normal')

Determines whether a given url can be cached or not by boost.

TODO: Add in support for the menu_item

Parameters

$parts: $parts

$request_type: May be 'status' to skip some checks in order to show the status block on the admin interface (otherwise we will always mention that the page is non-cacheable, since user is logged in). Please don't rely on this parameter if you are extending boost, this is likely to change in the future. Contact us if you use it.

Return value

$parts

2 calls to boost_is_cacheable()
boost_block_view_status in sites/all/modules/ulmus/boost/boost.blocks.inc
Prints the cache status of the currently displayed page.
boost_transform_url in sites/all/modules/ulmus/boost/boost.module
Given a URL give back eveything we know

File

sites/all/modules/ulmus/boost/boost.module, line 540
Caches generated output as a static file to be served directly from the webserver.

Code

function boost_is_cacheable($parts, $request_type = 'normal') {
  // Set local variables.
  $path = $parts['path'];
  $query = $parts['query'];
  $full = $parts['url_full'];
  $normal_path = $parts['normal_path'];
  $alias = $parts['path_alias'];
  $decoded = $parts['url_decoded'];

  // Never cache
  //  the user autocomplete/login/registration/password/reset/logout pages
  //  any admin pages
  //  comment reply pages
  //  node add page
  //  openid login page
  //  URL variables that contain / or \
  //  if incoming URL contains '..' or null bytes
  //  if decoded URL contains :// outside of the host portion of the url
  //  Limit the maximum directory nesting depth of the path
  //  Do not cache if destination is set.
  if ($normal_path == 'user' || preg_match('!^user/(autocomplete|login|register|password|reset|logout)!', $normal_path) || preg_match('!^admin!', $normal_path) || preg_match('!^comment/reply!', $normal_path) || preg_match('!^node/add!', $normal_path) || preg_match('!^openid/authenticate!', $normal_path) || strpos($query, '/') !== FALSE || strpos($query, "\\") !== FALSE || strpos($full, '..') !== FALSE || strpos($full, "\0") !== FALSE || count(explode('/', $path)) > 10 || strpos($decoded, "://") !== FALSE || !empty($query_array['destination'])) {
    $parts['is_cacheable'] = FALSE;
    $parts['is_cacheable_reason'] = 'Core Drupal dynamic pages';
    return $parts;
  }

  // Check for reserved characters if on windows.
  // http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
  // " * : < > |
  $chars = '"*:<>|';
  if (stristr(PHP_OS, 'WIN') && preg_match("/[" . $chars . "]/", $full)) {
    $parts['is_cacheable'] = FALSE;
    $parts['is_cacheable_reason'] = 'Reserved characters on MS Windows';
    return $parts;
  }

  // Match the user's cacheability settings against the path.
  // See http://api.drupal.org/api/function/block_block_list_alter/7
  $visibility = variable_get('boost_cacheability_option', BOOST_VISIBILITY_NOTLISTED);
  $pages_setting = variable_get('boost_cacheability_pages', BOOST_CACHEABILITY_PAGES);
  if ($pages_setting) {
    // Convert path string to lowercase. This allows comparison of the same path
    // with different case. Ex: /Page, /page, /PAGE.
    $pages = drupal_strtolower($pages_setting);
    if ($visibility < BOOST_VISIBILITY_PHP) {
      // Convert the alias to lowercase.
      $path = drupal_strtolower($alias);
      // Compare the lowercase internal and lowercase path alias (if any).
      $page_match = drupal_match_path($path, $pages);
      if ($path != $normal_path) {
        $page_match = $page_match || drupal_match_path($normal_path, $pages);
      }
      // When 'boost_cacheability_option' has a value of 0 (BOOST_VISIBILITY_NOTLISTED),
      // Boost will cache all pages except those listed in 'boost_cacheability_pages'.
      // When set to 1 (BOOST_VISIBILITY_LISTED), Boost will only cache those
      // pages listed in 'boost_cacheability_pages'.
      $page_match = !($visibility xor $page_match);
    }
    elseif (module_exists('php')) {
      $page_match = php_eval($pages_setting);
    }
    else {
      $page_match = FALSE;
    }
  }
  else {
    $page_match = TRUE;
  }

  $parts['is_cacheable'] = $page_match;

  if (! $page_match) {
    $parts['is_cacheable_reason'] = 'Page excluded from cache by the include/exclude paths defined by site admin.';
  }

  if (!$parts['is_cacheable']) {
    return $parts;
  }

  // Invoke hook_boost_is_cacheable($path).
  $modules = boost_module_implements('boost_is_cacheable', 'boost');
  foreach ($modules as $module) {
    $result = module_invoke($module, 'boost_is_cacheable', $parts, $request_type);
    if ($result['is_cacheable'] === FALSE) {
      if (! isset($result['is_cacheable'])) {
        $result['is_cacheable_reason'] = 'Page excluded from cache by a third-party module.';
      }

      return $result;
    }
  }

  return $result;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.