Caching

If you've ever seen a Slashdotted, Dugg, or Fireballed site suddenly fail to respond, you've witnessed the consequences of insufficient caching. A dynamic site has to query the database several times to assemble each page a visitor requests. Queries for a typical WordPress page include the bloginfo() options (site title, description, language, theme stylesheet URL), the post or page title and contents, the comments, and the sidebar widgets. If you're using multiple Loops, you're using even more queries. Servers can generally handle all those MySQL queries and PHP page-building functions for sites with low traffic, but when your site gets its fifteen minutes of fame—or gets hit with a denial of service attack— your server will probably buckle under the sudden demand.

The solution is to cache the assembled pages—that is, to store copies as static files in a hidden directory and to redirect incoming visitors to those copies rather than allow them to continually hammer your dynamic site. Not only does this speed things up for your visitors, but if you're on a shared hosting server, it will prevent you from exceeding your allotted CPU usage. Some hosts are nice about helping you keep the site up and running when that happens; others will just shut down your site to protect the other users on the server.

WordPress does not come with built-in caching. (This is perhaps the biggest criticism leveled at the WordPress project by users of other open-source content management systems.) It does come with support for a number of different caching options, and it's up to you to decide which plugin best suits your needs and your hosting environment. Cache plugins available at WordPress Extend include:

I'll walk through Super Cache, which is by far the most popular. First, though, take a look at your permalink settings. You must use a permalink structure other than the default in order for the caching plugins to work. Super Cache warns you if your permalink structure won't work, as shown in Figure 11-1. All of the cache plugins operate by using rewrite rules in your .htaccess file to redirect requests from your dynamic WordPress pages to static files saved in a hidden directory in your installation. If you aren't using permalinks, WordPress hasn't written any rewrite rules to . htaccess. If the rewrites never take place, your dynamic pages will be served up to your visitors even though you have installed and activated a caching plugin.

WP Super Cache Manager

Permlink Structure Error

A custom url or permalink structure is required for this plugin to work correctiy. Please 30 to the Permalinks Options Rape 10 configure your permalinks

Figure 11-1. WP Super Cache warning message on permalink structures

0 0

Post a comment