Evo_nginx_boost extension

July 19th, 2009


Introduction

The Evo_nginx_boost plugin allows us to cache pages generated in TYPO3 using memcache. This module can operate in two modes:

  • in conjunction with the NGINX proxy server –, see diagram
  • standalone – it is possible to read memcached pages directly from memcache. All it takes is a simple modification to the typo3_src/index.php file. The PHP process sends the exact memcache contents to the browser. As the focus is on high performance, the data is not serialized or processed in any way.

Requirements

  • PHP 5.X with memcache support
  • NGINX server (optionally)

Screenshots

Coniguration of evo_nginx_boost

Coniguration of evo_nginx_boost

Backend module

Backend module

Page memcache sesttings

Page memcache sesttings

Clearing memcache page

Clearing memcache page

How to install

Download the plugin from TER and install. Depending on the selected mode of operation, select one of the configurations from the section below.
If you decide to use a standalone installation, edit the typo3_src/index.php file, and add the following code before the line error_reporting (E_ALL ^ E_NOTICE):

require_once(’typo3conf/ext/evo_nginx_boost/tx_evonginxboost_index.php’);

The alternative solution, i.e. utilizing NGINX, is much more efficient. However, it requires installation of additional server-side software. You can read a detailed description of the required architecture and its operation in an earlier article, How to boost/speed up your TYPO3 website with nginx.

Konfiguracji evo_nginx_boost

Nginx

Property: Data type: Description: Default:
enable string enable disable memcaching 1
forceTimeoutToAllPages int set default memcache expiration time (has priority over TYPO3 setting) 0
disableCacheForLoogedUsers int enable/disable memcaching for logged users 0
cleanOnClearAllCache int if set, memcache is cleared when backend user click clear cache
setPageCacheTimeout OverrideAllTypoSettings (deprecated, always set to true) int if you enable this option, you can override all expires time from your user_int extension, fg if you have page with four extensions and each extension calls static function:

if (method_exists(’tx_evo_nginx_boost’, ’setPageCacheTimeout’)
tx_evo_nginx_boost::setPageCacheTimeout($timeout);

evo_nginx_boost set expire time to the lowest value set in all 4 plugins

1
_mainServerIP string memcache server ip
_mainServerPort string memcache server port
_mainServerPersistent int enable persistant connection 1
_mainServerTimeout string memcache server connection timeout 1
memcacheSignature int add signature to end o pages 1
memcacheSignatureText string text of signature fg “CACHED BY ME :) ”. If you set memcacheSignature = 1 time of expiration is added to the end of memcacheSignatureText 1
excludedUrls array Set in ext_localconf. This is array of urls which should be excluded from memcaching. Let say you have confirmation message after successfuly saving post in user’s blog. Page with message “your post was saved” will be memcached. You can add parameter message=1 and put this in array. Evo_nginx_boost exclude this url from memcaching. 1
cleanupAllowedFromIP string list of comma separated ip addresses from which Garbage Collector can be run [eID] 1
useUrlPrefixClear int if set, when POST is sent, cache is cleared for urls starting with request_url (referrer) instead page id, fg if you sent POST from page www.mysite.com/mysubpage/article1/ extension clears cache for pages www.mysite.com/mysubpage/article1/ www.mysite.com/mysubpage/article1/some/ www.mysite.com/mysubpage/article1/some2/ etc 0
garbageCollectorProbability float probability of starting garbabge collector, 1.0 = 1% 1.0
onlyLocalhost string set if memcache nginx and apacha are on the same server, domain is not added to memcache key 1
addCachedAnchorFlag string add special tag before closing body tag, you can check from js if page is from memcache 1
debug int start debugging 0
debugAllowedIP string list of comma separated ip addresses from which debug is generated 1
debugOnlyErrorsLogging int if set only errors are logged (browser and db table) 0
debugWriteToDB int if set, debug is written to db 0
debugWriteToOutput int if set, debug is written to browser (html source, bottom of page) 0
extendTypo3indexphp int set if you don’t want to use nginx, typo3_src/index.php should be changed 0

Per-page configuration

It is possible to set different caching configs for each page within a given tree. If no specific settings are made, evo_nginx_boost will read the default settings from config.cache_period. Furthermore, you may set various memcache settings for users that are logged in and logged out.  Example: during high-traffic hours on a forum Web site, the caching time for users who have not logged in may be set to 120 seconds, while the memcache may be disabled entirely for users who are logged in.

Per page configuration

Managing mecache.

Manual removal of data from memcache:

1. Through standard Clear FE cache function
2. Removal of memcache per page – invoked through a context menu for every page within a tree. See screen.
3. Recursive removal of memcache for an entire branch, also invoked through a context menu. See screen.

Automatic removal during POST send:

1. Memcache is removed for every page that had a POST send to it – unless the POST is added to the noClearCachePost table. This table can be found in the ext_localconf.php file.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['noClearCachePost'] = array ( // dont clear cache when one of this valudes is a key in $_POST array
  1.        'dontClearCache',
  2.        'logintype',
  3.    );

In addition, you can also use the excludedPost table. This table can contain POST types that be written to memcache by evo_nginx_boost as normal page requests. This is a nice feature to have if we have a search engine on our page and we want to memcache its results.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['excludedPost'] = array ( // This page will be stored in cache. Use to force memcache rewrite
  1. 'search',
  2. );

Excluding URl

The ability to omit URLs from the memcaching engine is a very useful feature as well. If, for example, we have a captcha on a Web page and we don’t want to memcache its requests, we can add an appropriate entry into the excludedUrls table. Again, you can find it in the ext_localconf.php file.

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['excludedUrls'] = array ( // perl regullar expressions
  1.        //'/ajax_load_id=[0-9]+/',
  2.        '/captcha.php?/',
  3.    );

Downloads:

-nginx configuration file
-wtyczka evo_nginx_boost ver 1.9.5

  • Share/Save/Bookmark