Example #1
0
 /**
  * Returns cache key
  *
  * @param string $sql
  * @return string
  */
 function _get_cache_key($sql)
 {
     $key = sprintf('w3tc_%s_sql_%s', w3_get_host_id(), md5($sql));
     /**
      * Allow to modify cache key by W3TC plugins
      */
     $key = w3tc_do_action('w3tc_dbcache_cache_key', $key);
     return $key;
 }
Example #2
0
 /**
  * Returns custom files key
  *
  * @param string $hash
  * @param string $type
  * @return string
  */
 function get_custom_data_key($hash, $type)
 {
     if ($this->_config->get_string('minify.engine') == 'file') {
         $key = sprintf('%s.%s.customdata', $hash, $type);
     } else {
         $key = sprintf('w3tc_%s_minify_customdata_%s', w3_get_host_id(), md5($hash . $type));
     }
     return $key;
 }
Example #3
0
 /**
  * Returns page key
  *
  * @param string $request_uri
  * @param string $mobile_group
  * @param string $referrer_group
  * @param string $encryption
  * @param string $compression
  * @return string
  */
 function _get_page_key($request_uri, $mobile_group = '', $referrer_group = '', $encryption = false, $compression = false)
 {
     // replace fragment
     $key = preg_replace('~#.*$~', '', $request_uri);
     if ($this->_enhanced_mode) {
         // URL decode
         $key = urldecode($key);
         // replace double slashes
         $key = preg_replace('~[/\\\\]+~', '/', $key);
         // replace query string
         $key = preg_replace('~\\?.*$~', '', $key);
         // replace index.php
         $key = str_replace('/index.php', '/', $key);
         // trim slash
         $key = ltrim($key, '/');
         if ($key && substr($key, -1) != '/') {
             $key .= '/';
         }
         $key .= '_index';
     } else {
         $key = sprintf('w3tc_%s_page_%s', w3_get_host_id(), md5($key));
     }
     /**
      * Append mobile group
      */
     if ($mobile_group) {
         $key .= '_' . $mobile_group;
     }
     /**
      * Append referrer group
      */
     if ($referrer_group) {
         $key .= '_' . $referrer_group;
     }
     /**
      * Append encryption
      */
     if ($encryption) {
         $key .= '_' . $encryption;
     }
     if ($this->_enhanced_mode) {
         /**
          * Append HTML extension
          */
         $key .= '.html';
         /**
          * Append compression extension
          */
         if ($compression) {
             $key .= '.' . $compression;
         }
     } else {
         /**
          * Append compression
          */
         if ($compression) {
             $key .= '_' . $compression;
         }
     }
     /**
      * Allow to modify page key by W3TC plugins
      */
     $key = w3tc_do_action('w3tc_pgcache_cache_key', $key);
     return $key;
 }