navigation

Full page cache with WP-Cache in WPMU

This is part of the caching for WPMU section of this blog, make sure to browse it for more information !

WP-Cache is quite an awesome plugin wor WordPress when you want performance improvements. Unlike the built-in object cache, WP-Cache works by not only caching objects, but caching complete HTML versions of a blog’s pages on disk and serving them directly until the cache is purged. This allows for super-fast page delivery, since it avoids all connections to database and script-loading.

Note : I won’t post here any of the files we actually use in our own implementation of WP-Cache (they are often too specific to our own systems and solutions), but will give the necessary advice to implement it properly.

Applied to WPMU, there are a number of factors to consider before you jump in and save your servers by implementing WP-Cache :

- You do not want to enable it on all blogs. WP-Cache writes a lot on disks (every page that is visited the first time, the first time after it was modified, or the first time after it expired). If a cached page isn’t visited at least a few timeswhile ithas an up-to-date cached versions, you probably spent more performance saving the page to disk than you saved with this cache. Also, a blog which receives tons of comments might not benefit that much from WP-Cache, because comments flush this cache and trigger a new disk write. We suggest having a static list of blogs for which you want the cache enabled, and use something along the lines of :

if(in_array(currentblog,listofblogs)) { define(« WP-CACHE »,true); }
- You need to be careful with your plugins. Some plugins *need* to have some dynamic information displayed on page to work properly. For unblog.fr, such plugins include : number of users online plugin (no point in this if you display a cache), statistics plugin (you need to log hits for your stats to be relevant even when the page is served from cache, spam karma 2 (needs some dynamic hash inserted in the page to ensure you actually loaded it before submitting a comment), referers plugins, and a couple of others.

WP-Cache is not very clear about what to do to keep some elements dynamic in the cached pages.

I will go through what needs to be done for SK2 to give you an idea of how you should adapt your plugins to keep things working correctly. The problem with SK2 is the « payload » plugin, which inserts a dynamic piece of HTML in the page to ensure it was actually loaded before submitting a comment. The existing function of the plugin we’re interested in reads :

function form_insert($post_ID)
{
$seed = $this->get_option_value(‘secret_seed’);
if (empty ($seed))
{
$seed = sk2_rand_str(10);
$this->set_option_value(‘secret_seed’, $seed);
$this->log_msg(__(« Resetting secret seed to: $seed. »), 5);
}
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$payload = md5($time . $seed . $ip . $post_ID);
echo « « ;
echo « « ;
echo « « ;
}

Good. Now what we need is to make sure those « input » tags stay dynamic even when served from the cache. To do this you must first inform WP-Cache that this section is dynamic, then tell it what function it’ll have to call to generate the dynamic information when the page is loaded from the cache : you can’t use your default plugin’s functions, because your plugin won’t have been loaded when WP-Cache serves the « static » page ! So you can modify your function like this :

function form_insert($post_ID)
{
$seed = $this->get_option_value(‘secret_seed’);
if (empty ($seed))
{
$seed = sk2_rand_str(10);
$this->set_option_value(‘secret_seed’, $seed);
$this->log_msg(__(« Resetting secret seed to: $seed. »), 5);
}
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$payload = md5($time . $seed . $ip . $post_ID);
echo « « ;

echo « « ;
echo « « ;
echo « « ;
echo « « ;

}

The « mfunc » tag tells WP-Cache that everything within it is dynamic, and will have to be replaced with whatever the function cached_sk2_javascript_payload will return.
Now all what’s left to do is create this function in a scope that’s visible from the WP-Cache scope (typically at the bottom of the advanced-cache.php file you’d have :

function cached_sk2_javascript_payload($seed,$postid) {
$time = time();
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$payload = md5($time . $seed . $ip . $postid);
echo « « ;
echo « « ;
echo « « ;
}

You can deal in this manner with any of your plugins that need dynamic content to be output or queries that need to be run even on cached pages : surround the dynamic page with the mfunc tag in the original plugin, then create the appropriate function and insert it in advanced-cache.php.

You’ll probably run in some trouble before you make everything work correctly in combination with WP-Cache. To keep you motivated, take a look at this graph, it shows the CPU usage on one of our HTTP servers the day we enabled WP-Cache for the top 30 most used blogs in our network. 60% decrease of CPU load !
wpcache.jpg

Using this plugin is by itself cutting our IT expenses almost in half. Good luck !

Commentaires»

1 2 3
  1. As it is a phone application as you could expect the thing is about swiping to kick like the best fifa professionals. Much hurling the ball, tapping that is.
    Basically it is a football game that is really great. I’ve just stumbled upon a nice new tablet shootout game and I’d love to present it to you. Mechanics are really simple yet hard to ace.
    Penalty kicks without all the unnecessary fooling around. After the download finishes you can commence shooting the football with kick flick mechanics. Soccer championships are at your sight, simply head to google play and grab the living sheet out of this bad boy. Witness the joy, the adrenaline, the tremor as you have peerless force over the football.
    By tapping you have to try to put the soccer ball into one of the targets. Fifa 2014 in Brazil is too sunny and dry for you? Experience the cool gust as you kick flick these penalty shots in this real football game.
    Champions league awaits, or should I say that it is happening all around the clock when you’re not playing, so better download it quick on google play. Penalty kicks were never so exciting! Be the best player in the European Cup. Pro Evolution Soccer can hide its dumb overcomplicated gameplay when Soccer World 14: Football Cup gets installed. Shootout league like in PES, that is Pro Evolution Soccer, only for android and other mobile phones.

  2. Tbull FTW. Coming from great Thunderbull this fresh underground racing game is the most dynamic endless racer game in the world. Games like this present you a lifetime opportunity to become the champion of roads. Traffic: Illegal Road Racing 5 is the most intensive street race fun ever since endless racer. Formula 1 racing was never that fast and fun. Best racing games of this are made for teenagers and adults alike. Drive as many auto as you can imagine and challenge yourself in this endless traffic racing entertainment. Asphalt overdrive shall crumble under your hot wheels as you race on countless American roads. Games like temple run and similar infinite racing games are made for everyday android players. Top endless runner game of the 2014. Get this best underground racer mobile game of google play for your android smartphone.

  3. You can play as a rushing champion or a kicker player. The championship of the champions rugby league is at the touch of your finger, so don’t hesitate and lunge for a field goal. You’ll get into the game and attempt to beat all of the numerous challenges. Graphics were made to impress with new smartphone technologies. The touchdowns you’ll make in the national rugby games shall get you fame among the stars of the super bowl matches. Rush through the stadium and get your place in the best rewinds of the moments of the year 2015. Score a goal for your dream team, e.g. seahawks or vikings. American football will see the best highlights of the year in this mobile app. Among the saints of NFL super bowl championships you’ll stand out as the greatest kick off cowboy. Game realism are obviously from the 2015 year. The feel of this nfl fantasy is maddening. Jump into the game and shine as a world famous NFL kicker – the chance will never come around again. Dive right into awesome national football emotions and get it from android this moment. Among the national champions kickers you’ll be the best and so you’ll get your place in the football highlights. Madden the opponents through fantasy kicking and kick offs in this fresh rugby app. Be like one of the packers or cowboys in the 15 super bowl matches. Achieve maddening penalty shots not different from soccer ball ace kicks.

  4. Just hit the screen of your android tablet and commence to fight for the awesome stakes of many players challenges in this carom billiards game. Anyhow it is simply the cue, the holes, the 9 snooker balls and you.
    Thine pool dexterity in billiards will be tested in these several contests given to you by top mobile games development company. Be the pool master either like a pro or in the casual style given here. Your journey through contrasting brands of billiards shall be cool and deadly. As you’ll have to knock the 8 ball into the one hole you will have to use the flexibility of perspective, as you can move your display in any target you prefer. Drawn artworks give edge to this app over its competitors. The indefinite amounts of play modes will bring you to your knees. This pool play presents you the decisive table test in numerous pool halls around the earth. Simply you and the straight rails when you con the kismeth with your skills.
    Luckily enough it has a training mode so you can work on your skills for how long you need to become the greatest snooker gamer in the world. Play english billiards, snooker or crokinole, whatsoever you want. No matter if you arrive from the China or Russia, there will be some national type of this good cue sport.
    Snooker or carrom, this sport has everything. As 8 ball pool this is a awesome mobile app.
    The best pool on android market game ever! Mobile version of one of the most popular games of skill ever. Custom making of the table is now in recreation history so sophisticated that other 8 ball pools can run and try one pocket with their grandmas.

  5. I have recently come across a new driving app for mobiles, it’s called Real Race: Asphalt Road Racing and it looks really like a racing sim with arcade feel. Driving through desert dunes and grasslands, avenues and lanes, it’s like Need for Speed Carbon or Most Wanted, and actually the latest edition, NFS: Rivals.
    On a scale of 1 to 10 I’d give it a strong 8. Selection of features is nearly staggering, and so is its replayability. Besting the leaderboards really caughts you and you are right away pulled in. It really reminds me of Asphalt Overdrive. Overall it’s a good, ambitious free game.
    There are no chases with the police, but perhaps it’s for the best as multiplayer asphalt gameplay gives great opportunity to demonstrate your unsurpassed underground drag racing skills.
    On-screen high speed gives an illusion of actually being there and hurrying with top drivers as seen in TV. Stress spikes are not far and few.
    It has very cutting-edge Artificial Inteligence and I’ve played already nine times successively or so and it’s still amusing and engaging. It’s kinda cool to drive and beat other racers on 6 or so maps. Game is similar to race with GT cars like lamborghini or asphalt.

  6. Drift mania in rally racing with next generation mechanics will satisfy any player. Dive head first deep into extreme driving action in this excellent fresh mobile production. Choose from the best GT cars, sit in front of the gears and kick the pedal to the floor. Life-like driving sim gives you the convenience to check your driving skills through plentiful challenges in intimidating avenues all around the world. Pick your car from many famous varieties such as ferrari, bugatti or audi. Burn the asphalt on 8 different courses as you race against the clock. Satisfy your need for speed by racing against other players in multiplayer mode. This overdrive android game lets you to compete with the best racers like a pro in NASCAR or Le Mans. Put your prowess to test and top the leaderboards while pushing your gt car to the limits of your need for speed. Even Need for Speed World was repetitive after some time which is not the case in this fast and furious spiritual descendant. Need for Racing: New Speed Car even gives you the possibility to customize your car by modding it in any way you’d like. Underground drag contest mixed with csr racing delivers the ultimate gameplay feel. The gameplay is arranged to hurl you in the heat of action as you race through the dust rising from the asphalt overdrive. As 8 races passed I still don’t feel tired by this game.

  7. Simply hit the display of your android phone and start to fight for the awesome stakes of multiplay tests in this carom billiards game. Anyhow it is simply the stick, the holes, the 9 pool balls and yourself.
    Your pool artistry in pool shall be tried in numerous tests given to you by this great game studio. Become the cue master either like a expert or in the arcade game type given here. Your course through different categories of snooker will be awesome and dangerous. As you’ll strive to knock the 9 ball into the one hole you will have to use the opportunity of perspective, as you can move your display in any course you wish. 2D graphics give edge to this aplication over its contestants. The indefinite supply of play styles will bring you to your edge. This cue play gives you the ultimate table test in numerous snooker lobbies all over the earth. Simply you and the straight rails as you con the destiny with your artistry.
    For your luck it has a training mode so you will work on your dexterity for how long you will feel the need to become the pro cue gamer in the known universe. Have a game of english billiards, pro pool or crokinole, whatsoever you prefer. Whether you arrive from the UK or France, there will be some native type of this great cue game.
    Crokinole or carrom, this thing has everything. As 10 ball pool this is a awesome android app.
    The greatest snooker on android market entertaiment up to this time! Simulation of one of the best games of skill anytime. Tailoring of the playstyle is this time in gaming history so smooth that other 10 pro billiards can go and try hide and seek with their grandmothers.

  8. Plunge straight deep into hardcore driving action in this sweet fresh android production. Choose from the fastest GT cars, sit in front of the gears and kick the pedal to the floor. Life-like driving sim allows you the freedom to check your driving prowess through diverse challenges in intimidating tracks all around the world. Drift mania in rally racing with next-gen mechanics will amuse anyone. Pick your car from many famous brands such as ferrari, bugatti or audi. Entertain your need for speed by racing against players in multiplayer mode. This overdrive mobile game allows you to race with top racers like a professional in Monaco or Le Mans. Scorch the asphalt on 8 different courses as you race against the clock. Put your expertise to test and top the leaderboards while pushing your gt car to the limits of your need for speed. Underground drag competition intertwined with csr racing delivers the ultimate gameplay experience. The gameplay model is arranged to drop you in the middle of action as you race through the dust rising from the asphalt overdrive. As 8 races passed I still don’t feel tired by this app. Even Need for Speed World started to be repetitive after a little time which is not the case in this fast and furious spiritual offspring. Need for Racing: New Speed Car even gives you the possibility to customize your car by modding it anyhow you choose.

  9. This superb and fresh first person shooter will take you away into a world of pain. Mass Effect is really based on that smartphone entertainment. As you fight through a bunch of cyber enemies. Do not look back and proceed with the shooting. Call of Duty: Advanced Warfare is the thing that truly rustles player’s jimmies. This kind first person shooter entertainments is a new type of wasting some free passtime in your smartphone. When the grim dark imagining of distant future, there is nothing but combat with androids. Frontline commando attacks in far battlefield in mass effect. The game is made with simple swipe control for your entertainment. Mass effect at it’s best. Frontline commando is an app for android and it is possible to get it on google play. That type of first person shooter games are the doom of your pastime. Try and place yourself in this mass effect esque game. This shooting game will set you free.

1 2 3

Laisser un commentaire

Le Web Rémunéré |
les codes pokemon |
........l'univers de TINTIN... |
Unblog.fr | Annuaire | Signaler un abus | nateeve05.blogee.com
| BOUCHEKFA
| riadsfes