You are here

function esi_init in ESI: Edge Side Includes 7.3

Same name and namespace in other branches
  1. 6.2 esi.module \esi_init()

Implements hook_init().

File

./esi.module, line 117
Adds support for ESI (Edge-Side-Include) integration, allowing components\ to be delivered by ESI, with support for per-component cache times.

Code

function esi_init() {

  // Add the AJAX fallback handler, if it's enabled.
  if (variable_get('esi_ajax_fallback', ESI_DEFAULT_AJAX_FALLBACK)) {
    $path = drupal_get_path('module', 'esi');
    drupal_add_js("{$path}/js/esi.js");
    drupal_add_js("{$path}/js/jquery.esi.js");

    // Contextualize the URLs, if required.
    // Drupal.ESI.contextualize_URLs
    if (variable_get('esi_ajax_fallback_contextualize_url', ESI_DEFAULT_AJAX_FALLBACK_CONTEXTUALIZE_URL)) {
      $harden_cookies = variable_get('esi_harden_cookie_key', ESI_DEFAULT_CONTEXT_COOKIES_HARDENING);
      $setting = array(
        'ESI' => array(
          'cookie_prefix' => variable_get('esi_cookie_name_prefix', ESI_DEFAULT_COOKIE_NAME_PREFIX),
          'cookie_suffix' => $harden_cookies ? '_' . session_name() : '',
          'contextualize_URLs' => TRUE,
        ),
      );
      drupal_add_js($setting, 'setting');
    }
  }
}