Reverse-Proxy Cache and WPMU

This is our latest article in the WordPress MU Caching section, make sure you checked out the others !

This article is the less versatile of the ones I wrote in this section, because it will only be interesting to you if you if you have (or plan to have) a multi-server architecture. In this case it’s likely you’ve separated HTTP and SQL servers, and if your platform is big enough that you have multiple HTTP servers. Then, you need a way to dispatch users across the different HTTP servers. While you may have a load balancer, which is the most robust solution to do this (and the single point of failure the least likely to fail), another solution is to use a reverse proxy on a front server. This server can handle all incoming requests, and then route them to abackend HTTP server.

There’s plenty of things you can have the reverse proxy do that will decrease the load on your backend servers without endangering too much its stability, like security (IP banning etc.), content compression (gzip), and another very interesting one is caching.
It is one of the biggest flows in wordpress in my opinion that whenever you load a static file (image, music, office document, etc.), it has to go through PHP and then run many SQL queries just to load this static file. This prevents you, if you don’t want to hack the files manipulating uploads, from using a lightweight HTTP server to serve those static files, and this generates unnecessary load on your machines. Using a cache at the reverse proxy level can help solve this problems : basically the first time a static file is accesse, it will get cached on the reverse proxy server, and all subsequent requests to this file will be served directly from the front end machine, without needing php or mysql.

There are many software solutions for reverse proxies, including Apache 2 with mod_proxy, lighttpd, Squid or Nginx (this last doesn’t have the caching option though).

It’s fairly easy to configure apache 2 with mod_proxy, to give an idea here is a sample configuration :

# Cache static files on disk

CacheRoot /home/cache
CacheMaxFileSize 1000000
CacheEnable disk /files
CacheDirLevels 2
CacheDirLength 1

# Cache avatars in memory

MCacheMaxObjectCount 10000
MCacheSize 50000
CacheEnable mem /wp-content/avatars

Some warnings :

Caching files on the reverse proxy machine may mean lots of disk accesses for this machine, so make sure it has fast disks and/or cache what can be in memory rather than on disk.

Caching can cause problems if for instance you need to remove a blog that is against the law. Its files will stay in cache until purged, so removing them right away might mean flushing your cache completely.

Apache doesn’t have implemented yet a garbage collection for mod_cache. To prevent your cache from getting too big and/or full of useless files run something like this in cron :

30 3 * * * root /usr/sbin/tmpwatch -fud 72 /home/cache/ >/dev/null 2>/dev/null

This will remove from your cache the files that were not accessed in the past 72 hours.

Happy proxying :) .


1 2 3 19
  1. this is great, thanks. Could you provide more details on the different pieces involved?

  2. The time to read or stop by the content or web sites we’ve linked to beneath.

  3. I visited various websites but the audio feature for audio songs current at this
    web page is genuinely marvelous.

    Feel free to surf to my blog post :: Outsourcing

  4. The second forms of banner will assist you to put as much as 5 products per banner when you intend to
    use. For discussion purposes, let’s take for example Clickbank.
    Article Source: Jamieson is an in demand voice over artist, copywriter and internet marketer.
    Members might also get access to a private forum where experienced coaches offer support and motivation, or they can chat
    to other members about their ongoing weight loss journey. And
    you arent getting that bad karma coming back your way.
    Now that you’ve got your wordpress build, it is time to start.
    Click – Bank will pay the vendor and the affiliate, this
    make it a very easy process.

  5. I’ll immediately grasp your rss feed as I can not find your email subscription link or newsletter service. Do you have any? Please permit me know in order that I may just subscribe. Thanks.
    maillot paris

  6. It is the best time to make a few plans for the long run and it’s time to be happy. I’ve learn this post and if I could I want to recommend you some interesting issues or advice. Perhaps you can write next articles regarding this article. I wish to learn even more things about it!
    maillot de foot enfant pas cher

  7. I constantly spent my half an hour to read this web site’s content everyday along with a cup of coffee.
    maillot Robben enfant

  8. Hey there, I think your blog might be having browser compatibility issues.
    When I look at your blog in Ie, it looks fine
    but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that,
    amazing blog!

    Review my weblog – home designs ideas (

  9. Eхcellent article, j’espère en parler dans la soirée avec des

    My bloց post; partouze hardcore

  10. golf fl 32830like [url=]Hollister Pas Cher[/url] disney’s all star movies resort

    You’re already giving up a little [url=][/url] bit of [url=]cheap moncler jackets[/url] ownership by agreeing that this [url=]ralph lauren outlet[/url] separate product, [url=]moncler uk[/url] the game, is only for use in conjunction with this other product, the console. It’s not like a DVD player you can’t play that game on a Vizio brand PlayStation 3. It’s proprietary.

    [url=]moncler uk[/url]
    [url=]barbour sale[/url]
    [url=]cheap barbour jackets[/url]
    [url=]ralph lauren outlet[/url]
    [url=]ralph lauren sale[/url]
    [url=]polo ralph lauren uk[/url]
    [url=]ralph lauren outlet uk[/url]
    [url=]ralph lauren sale uk[/url]
    [url=]ralph lauren outlet online[/url]
    [url=]cheap ralph lauren polo[/url]
    [url=]polo ralph lauren pas cher[/url]
    [url=]ralph lauren outlet[/url]
    [url=]moncler outlet uk[/url]
    [url=]cheap moncler jackets[/url]
    [url=]canada goose pas cher[/url]
    [url=]canada goose outlet[/url]
    [url=]canada goose jackets sale[/url]
    [url=]oakley sunglasses outlet[/url]
    [url=]Cheap Christian Louboutin Shoes[/url]
    [url=]Louboutin Shoes Outlet UK[/url]
    [url=]Cheap Christian Louboutin Shoes[/url]
    [url=]Louis Vuitton Handbsgs Outlet UK[/url]

  11. of course like your website however you have to test the spelling on quite
    a few of your posts. Many of them are rife with spelling problems and
    I find it very troublesome to inform the reality nevertheless
    I’ll definitely come again again.

    Stop by my weblog soundcloud downloader free download

  12. Thanks a bunch for sharing this with all folks you actually know what you are speaking approximately!
    Bookmarked. Kindly additionally seek advice from my site
    =). We may have a link change arrangement between us

    My web blog; iherb best products

  13. The snow capped mountains inform us that he has many tall aims
    and aspirations. If you have particular objectives, you will find support even if you have to be a group player, and not the star.

    Also visit my page – authentic psychic readings

  14. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You clearly know what youre talking about, why throw away your intelligence on just posting videos to your blog when you could be
    giving us something informative to read?

    Feel free to visit my web page; online Psn Code generator

  15. Nice post. I was checking constantly this weblog and I’m impressed!
    Very helpful information specially the last part :) I care for such information much.
    I was seeking this certain information for a long time.
    Thanks and best of luck.

    My website … Psn Code Generator No Surveys

  16. Hey there just wanted to give you a brief heads up and let you know a few of the images aren’t loading correctly.
    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different web browsers and both show the same

    My homepage … soundcloud Downloader pc

  17. If some one needs to be updated with hottest technologies therefore he must be pay a visit this website and be up to date daily.

    my blog How to download from soundcloud

  18. My coder is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using
    WordPress on various websites for about a year and am anxious about switching to another platform.

    I have heard excellent things about
    Is there a way I can import all my wordpress posts into it?
    Any help would be greatly appreciated!

    my site: soundcloud downloader App

  19. We stumbled over here different page and thought I might
    check things out. I like what I see so now
    i am following you. Look forward to looking over your web page for a second time.

    Feel free to surf to my webpage – soundcloud downloader online

  20. I think the admin of this website is in fact working hard
    for his web page, for the reason that here every information is quality based material.

    Also visit my webpage – best soundcloud downloader –,

1 2 3 19

Laisser un commentaire

Le Web Rémunéré |
les codes pokemon |
........l'univers de TINTIN... | | Créer un blog | Annuaire | Signaler un abus |
| riadsfes