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. just beneath, are a lot of entirely not associated websites to ours, nevertheless, they’re certainly worth going over

  2. Sites of interest we have a link to

  3. always a significant fan of linking to bloggers that I appreciate but do not get lots of link like from

  4. Wonderful story, reckoned we could combine a couple of unrelated data, nonetheless seriously really worth taking a appear, whoa did one understand about Mid East has got far more problerms also

  5. we came across a cool web-site which you could possibly enjoy. Take a search in the event you want

  6. please pay a visit to the internet sites we adhere to, such as this a single, as it represents our picks in the web

  7. the time to read or pay a visit to the content or sites we’ve linked to below the

  8. Thanks for your personal marvelous posting! I definitely enjoyed reading it,
    you can be a great author. I will make sure to bookmark your blog
    and definitely will come back down the road. I want to encourage
    continue your great writing, have a nice holiday weekend!

  9. Here is a good Weblog You might Uncover Exciting that we encourage you to visit.

  10. Sexdating-40plus nl bieddt je de mogelijkheid om in contact te komen met diverse dames en sexdate of heren. Als je vrienden en je kennissen. Door
    de gigantische grei iin leden, wordt hhet steeds leuker!
    De tweede opmerking over heet aanbod. ’ Twee weken later.
    Minder dann eenn uur per dag 7 dagen per week, en 1 miljoen mensen vrijgezel.

    Alleen zullen nooit zoo snel gaan groeen als Grindr. Dit is vanaf nu verleden tijd, want dat
    vond zze heel lekker.

    my website :: gratis sex dating

  11. Kiki Anoniem, 05-01-2011 22:54 #24Heee, Ik vind dit
    wel een punt waar Singless United een aantal clubSexdates: spetterende
    voorstellingen, die veel stof bieden tot napraten.

    Review my blog gratis sex dating (tubex.nl)

  12. Navigatie Chatten met vreemden “om een leuke band sexdate op boiuwen.
    Plots viel toen de hele klas beschouwd als het ‘meisje dat em leuk heeft gevonden’.
    De beste sexdatingvsites voor het uitbreiden van hun sociale contacten via ezamenlijke interesses een activiteiten.
    Dan wordt het tijd oom die pakkende tekst tte schrijven. Af en toee overvalt mee dan weer
    het gevoel: wwas ik maar terug bij sexdate ex.

    my homepage; gratis ssex date (http://sexcontactchatboxtemptationdatingswingersgratissexdateonline.nl)

  13. I’m amazed, I have to admit. Rarely do I encounter
    a blog that’s both educative and entertaining, and without a doubt, you’ve hit the nail on the head.
    The issue is an issue that too few people are speaking
    intelligently about. I’m very happy that I stumbled across this
    in my search for something relating to this.

    Here is my weblog – rencontre cougar

  14. You have made some really good points there. I looked on the internet to find out more
    about the issue and found most people will go along with your views on this site.

    My web site; site de rencontre cougar sans engagement

  15. I really love your website.. Pleasant colors & theme. Did you create this website yourself? Please reply back as I’m planning to create my own personal website and would like to find out where you got this from or exactly what the theme is named. Cheers!
    maillot psg 2014 http://www.nastrificiodebernardi.com/images/maillot-de-foot-psg.html

  16. Hey would you mind letting me know which web host you’re working with? I’ve loaded your blog in 3 different internet browsers and I must say this blog loads a lot faster then most. Can you recommend a good web hosting provider at a honest price? Kudos, I appreciate it!
    maillot de l ol https://nvicadvocacy.org/aspnet_client/maillot-ol-pas-cher.html

  17. My coder is trying to convince me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using Movable-type on a variety of websites for about a year and am nervous about switching to another platform. I have heard fantastic things about blogengine.net. Is there a way I can import all my wordpress posts into it? Any kind of help would be greatly appreciated!
    camisetas atletico de madrid baratas http://www.clinique-princess.com/es/camiseta-atletico-de-madrid-2014.html

  18. I simply couldn’t depart your web site before suggesting that I really enjoyed the standard information a person supply on your guests? Is going to be back incessantly in order to inspect new posts
    [url=http://www.hn-jx.com/member/maillot-van-Persie-pas-cher.html]maillot van Persie enfant[/url]

  19. The invading aliens shall require the intervention of a strong frontline commando. Fighting and running can be tiresome but you will keep that hand on the dead trigger. Become the humanity’s first chance while you kill the countless influx of bug baddies. First person shooters were never as cool as that free and nice mobile android game. The dead space has given birth to an earth assault and you’re the only modern warfare frontline commando to kill it. This fps (first person shooter) game will give you with loads of free fun on google play. Don’t be afraid and pack a large shadowgun. While you’ll go on with the free fun you shall go on in deteriorated cities close to their doom. Stand your ground and use two guns at the same time. Post apo battlefield will need your domination on the leaderboards. Live, die repeat. Be the ultimate terminator and alien deer hunter. Heed your call of duty and shoot the aliens. Best the enemy and best the ominously transgressing chances as you shall carry on with your call of duty. The modern warfare battlefield will give you your call of duty. When the call of duty calls it is a must for you to go on an ginormous odyssey and killing undead zombie bugs.

  20. Right from great Thunderbull this new underground race fun game is the best endless racing game of this universe. Best racing mobile games of this type are done for kids and adults alike. Asphalt 7 shall crumble behind your hot wheels when you race through countless American streets. Games in the style of temple run and similar infinite racers are made for casual android gamers. Best endless racing play of the 2014. Get this quick illegal racing mobile game at google play for the android phone. Race as many cars as you could think of and race in multiplayer infinite traffic racer fun. Apps like endless racer give you with a unique chance to become the master of roads. Traffic: Illegal Road Racing 5 is the fastest street racing fun since zombie highway. Rally racing was never that fast and entertaining. Tbull FTW.

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