Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

To improve site/page performance, I added the following code to accept headers:

<php flush(); ?>

It works, but perhaps not as well as it could. Any advice?

I also tried to leverage browser caching, using the following code:

# Begin Expires Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
# End Expires Caching

Again, any advice to optimize the results will be appreciated.

share|improve this question
    
Please migrate back to wherever this question came from. It has absolutely nothing to do with WordPress. –  Chip Bennett Feb 29 '12 at 20:55
3  
@ChipBennett: But the title is about improving the performance of WP sites. It's just that the examples of what he's tried so far are not WP-specific. –  Dougal Campbell Feb 29 '12 at 21:09
add comment

migrated from webmasters.stackexchange.com Feb 29 '12 at 20:39

This question came from our site for pro webmasters.

4 Answers

The most common thing to try is a content caching plugin like W3 Total Cache or WP Super Cache. Both will cache entire pages to disk, and will allow the Apache web server to completely bypass PHP processing for many page views. With W3 Total Cache, you can also cache system objects and the results of database queries, as well as using a CDN (Content Distribution Network) or a local memory cache server such as memcached, APC, or XCache. Additionally, it can perform combination and minimization of your CSS and JS, which can be a performance win (by reducing the number of requests a browser must make).

Other strategies include combining images into a single sprite image, and using CSS display only the appropriate portion. This reduces the number of separate images the browser must download.

Other possibilities, which require a lot more work/knowledge/resources: Switch from Apache to Nginx or some other high-performance web server. Switch from mod_php to mod_fastcgi + php-fpm. Implement multiple backends for your web server, with a high-performance caching proxy server in front. Multiple MySQL servers.

share|improve this answer
    
Jared, Chip - Websites can be improved at the CMS- and server level, which includes Apache. - Dougal - We did try cache plugins, including W3 Total Cache and WP Super Cache, but several client sites experienced incompatibilities with other plugins and the sites were in bad shape. This is why we like to continue the server approach. –  Emma Mar 1 '12 at 17:15
add comment

The best option is to use a cache plugin. I also recommend W3 Total Cache, but before installing it, make sure you backup your database and files and update wordpress to the latest version.

Wordpress is causing the highest load on the database. The processor will have to work hard to retreive the data if there are many queries at the same time. Caching plugin will try to provide already extracted content if he notices that nothing else changed.

Caching the images, scripts and documents will only save your bandwidth, which is not the main problem of wordpress. It is ok to optimize images and scripts to save bandwidth, but they are just files that are given as they are. The problem appears when the wordpress engine retreive the data from database.

If you do a detailed load speed test on your website you will notice that at least half of the loading speed is caused by "Waiting". Your browser is waiting for the server to retreive the data and process it. If you do the same test on a static page then that time is almost to 0. The other half of the time is actual time spent downloading images, which depends on your server bandwidth. IF you cache and optimize all images and scripts you will be able to save 20-50% of that time too, but you must be aware that browsers already have default caching system that will store scripts and images.

share|improve this answer
add comment

The usual approach to optimising a Wordpress website is using a plugin like W3 Total Cache, but what a lot of people fail to realise and you've discovered is that such plugins have a slew of compatibility issues with other plugins as well as various hosts. The plugin W3 Total Cache does a good job at working with a whole heap of different server configurations, but usually at the cost of using optimal settings.

Some things you can try when optimising a Wordpress site that don't require plugins are:

  1. Use a content delivery network (CDN) - Amazon have a great offering called Cloudfront which if you are familiar with CDN's will reduce site HTTP requests as a browser can generally only have 2 concurrent HTTP connections to one server. Cloudfront will also server your files from servers close to that of the visitor so they get the most ideal transfer speeds and less connection hops which means a quicker page load.

    If you don't want to pay for a CDN, you can trick a browser into thinking it's loading off of a CDN by adding in subdomains that map to your actual domain. A subdomain is considered a separate domain and therefore frees up a request on your regular domain. For example your usual site is: http://www.somesite.com, a fake CDN would be http://images1.somesite.com/imagefile.jpg, http://images2.somesite.com/imagefile2.jpg and so on. I usually add about 4 or 6 and then use either javascript or PHP to randomly append the subdomains to image urls.

  2. Combine and minify your stylesheets and scripts - There are plugins for Wordpress that can combine all JS and CSS on your site for you, but for ultimate control do it yourself if you can.

  3. Use CSS image sprites - For every image your site loads it makes a request, for background images you can combine them into one larger image and use the background-position property to navigate around it. Read about sprites here.

  4. Add an Expires or a Cache-Control Header - This essentially tells the visitors browser when to retrieve new files from your server and when to load them from your cache instead. Read about mod_expires here.

  5. Configure ETags - Rather then reiterate what has already been said elsewhere, this Yahoo! article will explain what ETags are and how to configure them correctly.

  6. Use Flush() - Using the PHP flush function allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. Put it right after your closing head tag like so: </head><?php flush(); ?>

share|improve this answer
add comment

So that I don't repeat the same information. Few months ago, I wrote a tutorial on: 14 Tips for Maximum WordPress Performance & Speed

Hope this Helps.

Boutros.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.