<code>$key = '/index.php?';</code>
<code>$modx->cacheManager->set($key , $modx->resource->_output, $expire);</code>
"default/$args"
memcache зараза страницу компрессирует как ни крути
вообще лишнее, можно выкинуть…
и в nginx правильнее наверно будет «default/$args»
и добавить еще $expire
насчет побьется я не совсем уверен, так как неделю назад вообще про nginx не слышал. Но я думаю ты ошибаешся… Пройдись по конфигу nginx и посмотри логику.
# Именнованная лакация (правило) location @modx { # выполняем подмену на index.php rewrite ^/(.*)$ /index.php?q=$1 last; }
# устанавливаем ключ-переменную для запроса к мемкешу set $memcached_key "default/$uri?$args";
При чем тут реальные файлы?
# Именнованная лакация (правило) location @modx { # выполняем подмену на index.php rewrite ^/(.*)$ /index.php?q=$1 last; }
$query = '/'; $query_str = str_replace('&', '&',($_SERVER['QUERY_STRING'])); if(!empty($query_vars['q'])){ $query .= $query_vars['q']; unset($query_vars['q']); } else{ $query .= 'index.php'; } $query .= "?"; $vars = array(); foreach($query_vars as $k => $v){ $vars[] = "{$k}={$v}"; } if($vars){ $query .= implode("&", $vars); } $modx->log(1, print_r($query, 1)); $modx->cacheManager->set($query , $modx->resource->_output);
('memcached_server', $options, 'localhost:11211')
$config_options = array ( "cache_handler" => "cache.xPDOMemCached", 'memcached_server' => 'unix:///var/run/memcached/mem.socket', 'system_settings_memcached_server' => 'unix:///var/run/memcached/mem.socket', 'db_memcached_server' => 'unix:///var/run/memcached/mem.socket', );
$memcache->connect('localhost', 11211)
$memcache->connect('unix:///var/run/memcached/mem.socket', 0)
$servers = explode(',', $this->getOption($this->key . '_memcached_server', $options, $this->getOption('memcached_server', $options, 'localhost:11211'))); foreach ($servers as $server) { $server = explode(':', $server); $this->memcache->addServer($server[0], (integer) $server[1]); } $compressThreshold = $this->getOption($this->key . '_memcached_compress_threshold', $options, $this->getOption('memcached_compress_threshold', array(), '20000:0.2'));
$compressThreshold = $this->getOption($this->key . '_memcached_compress_threshold', $options, $this->getOption('memcached_compress_threshold', array(), '20000:0.2'));
$servers = explode(',', $this->getOption($this->key . '_memcached_server', $options, $this->getOption('memcached_server', $options, 'localhost:11211')));
$this->memcached->setOption(Memcached::OPT_COMPRESSION, (boolean) $this->getOption($this->key . '_memcached_compression', $options, $this->getOption('memcached_compression', $options, $this->getOption(Memcached::OPT_COMPRESSION, $options, true))));
'unix:///var/run/memcached/mem.socket', 0
Error caching time of next auto publishing event Could not cache context settings for mgr. Could not cache context settings for web.
я в коде не разбираюсь но у меня чувство что explode(':', $server)
$servers = explode(',', $this->getOption($this->key . '_memcached_server', $options, $this->getOption('memcached_server', $options, 'unix:///var/run/memcached/mem.socket')));
$this->memcached->addServer('unix:///var/run/memcached/mem.socket', 0);
$servers_default = $this->getOption('memcached_server', $options, 'unix:///var/run/memcached/mem.socket'); $servers_str = $this->getOption($this->key . '_memcached_server', $options, $servers_default); $servers = (array)explode(',', $servers_str);
Error caching time of next auto publishing event Could not cache context settings for mgr. Could not cache context settings for web.
$options= array())
$this->memcached->setOption(Memcached::OPT_COMPRESSION, (boolean) $this->getOption($this->key . '_memcached_compression', $options, $this->getOption('memcached_compression', $options, $this->getOption(Memcached::OPT_COMPRESSION, $options, true))));
<?php switch($modx->event->name){ case 'OnWebPageComplete': if (!empty($modx->resource) && $modx->resource->get('cacheable') && $modx->resource->get('published') && $modx->resource->_output != '' && $_SERVER['REQUEST_METHOD'] == 'GET' ) { $key = 'index.php?'; $key .= str_replace('&', '&',($_SERVER['QUERY_STRING'])); $modx->log(1, "Key: '{$key}'"); $modx->cacheManager->set($key , $modx->resource->_output); } break; default:; }
$key = 'index.php?';
$this->key . '/' . $key;
set $memcached_key "site.com$uri?$args";
Проверка на GET чтобы если отправили форму не кешировалась страница с ответом.
[2016-03-12 15:23:52] (ERROR @ /index.php) Key: '/index.php?q=news/1453/' [2016-03-12 15:23:54] (ERROR @ /index.php) Key: '/index.php?' [2016-03-12 15:25:26] (ERROR @ /index.php) Key: '/index.php?'