Mastering WordPress Vol.1

1,704 views

Published on

About improving performance of a site using WordPress.
- Identifying bottlenecks
- Improvement with plugins
- Improvement on the server side

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,704
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
50
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Mastering WordPress Vol.1

  1. 1. Mastering WordPress Vol.1 2012.08.23 - wokamoto
  2. 2. Introduce MyselfI’m a member of WordPress Plugins/JSeries, and making WordPress plugins. Head Cleaner - Cleaning tags from your WordPress header and footer. OAuth Provider - A plugin to allow WordPress to use an OAuth authenticator. http://profiles.wordpress.org/wokamoto
  3. 3. I’ve just released AMI which isperformance tuned forWordPress . http://megumi-cloud.com/
  4. 4. Recntly I’ve written a book.WordPress speeding up & smart operation must-have guide
  5. 5. OutlineAbout improving performance of asite using WordPress Identifying bottlenecks Improvement with plugins Improvement on the server side
  6. 6. Identifying bottlenecks
  7. 7. The reasons of slowness PHP processing is slow MySQL processing is slow Problem of Internet line
  8. 8. PHP processing is slowPlugins or themes are inefficientWordPress runs futilelyToo many access to process
  9. 9. MySQL processing is slow Too many plugins cause too many queries Queries are not properly optimized MySQL is not properly optimized
  10. 10. Problem of Internet line Many big files such as images Loads many CSS, JS files JS loaded from outside is slow
  11. 11. Debug Bar andDebug Bar Extendar
  12. 12. http://wordpress.org/extend/plugins/debug-bar/http://wordpress.org/extend/plugins/debug-bar-extender/
  13. 13. After installed the plugins, add thelines below to wp-config.php define(SAVEQUERIES, true); define(WP_DEBUG, true); define(WP_DEBUG_DISPLAY, false);
  14. 14. Identifying bottlenecks with Debug Bar
  15. 15. Add check point to the Profile tab of Debug Bar to show<?phpif ( function_exists("dbgx_checkpoint") ) dbgx_checkpoint( $note="Note" );?>
  16. 16. Try not to runWordPress as few as possible
  17. 17. Accessing to non-existent files makes WordPress run# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress
  18. 18. Files that browser crawlers check for the presence of /favicon.ico /apple-touch-icon.png /robots.txt /crossdomain.xml
  19. 19. # BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME}! !.(html?|xml|txt|xsl|js|css|jpe?g|png|gif|ico)$RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress
  20. 20. Avoid duplication of JavaScript
  21. 21. <?php wp_enqueue_script(jquery); ?>
  22. 22. Using only jQuery on its’ Google AJAX Libraries<?phpwp_deregister_script(jquery);wp_enqueue_script( jquery, http:/ /ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js, array(), 1.7.2);?>
  23. 23. Setting periods ofvalidity for static files
  24. 24. <IfModule mod_expires.c>ExpiresActive OnExpiresDefault "access plus 1 seconds"ExpiresByType text/html "access plus 1 seconds"ExpiresByType image/gif "access plus 30 days"ExpiresByType image/jpeg "access plus 30 days"ExpiresByType image/png "access plus 30 days"ExpiresByType image/x-icon "access plus 30 days"ExpiresByType text/css "access plus 7 days"ExpiresByType text/javascript "access plus 7 days"ExpiresByType application/x-javascript "access plus 7 days"</IfModule>
  25. 25. Note for setting Expireswp_enqueue_style( my-theme-style, get_template_directory_uri() . /style.css, array(), date(YmdHis, filemtime(get_template_directory() . /style.css) ) );
  26. 26. Sending text files with gzip compressed
  27. 27. <IfModule mod_deflate.c>SetOutputFilter DEFLATEBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4.0[678] no-gzipBrowserMatch bMSIE/[1-6] !no-gzip !gzip-only-text/htmlSetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|ico|pdf)$no-gzip dont-varySetEnvIfNoCase Request_URI _.utxt$ no-gzipDeflateCompressionLevel 4AddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE application/x-javascriptAddOutputFilterByType DEFLATE application/x-httpd-php</IfModule>
  28. 28. Try to avoidusing .htaccess
  29. 29. When AllowOverride is enabled to /, then/wp-includes/js/jquery/jquery.js is accessed, Apachecheckes every files below. /.htaccess /wp-includes/.htaccess /wp-includes/js/.htaccess /wp-includes/js/jquery/.htaccess
  30. 30. Optimizing image files
  31. 31. http://wordpress.org/extend/plugins/wp-smushit/
  32. 32. Dividing sources into several servers
  33. 33. http://wordpress.org/extend/plugins/wp-flickr-press/
  34. 34. http://wordpress.org/extend/plugins/tantan-s3/
  35. 35. Distributing contents using CDN
  36. 36. http://wordpress.org/extend/plugins/wpbooster-cdn-client/
  37. 37. Optimizing CSS and JS
  38. 38. http://wordpress.org/extend/plugins/head-cleaner/
  39. 39. Disabled
  40. 40. Enabled
  41. 41. Cache outputs of WordPress
  42. 42. Object Cache
  43. 43. Common case of speed up WordPress<?php bloginfo(stylesheet_url) ?>Writing template tags in theme files causes accessingMySQL server and makes it slow, so let’s write CSS’s URLin theme files.http://example.jp/wp-content/themes/example/style.css残念ながら、この手法にはあまり効果がありません。
  44. 44. wp_cache_add( $key, $data, $group )wp_cache_replace( $key, $data, $group )wp_cache_set( $key, $data, $group )wp_cache_get( $key, $group )wp_cache_delete( $key, $group )wp_cache_flush()
  45. 45. Object cached data are usually discarded every time.
  46. 46. Plugins to use persistently object cached data.http://wordpress.org/extend/plugins/wp-file-cache/http://wordpress.org/extend/plugins/apc/http://wordpress.org/extend/plugins/memcached/
  47. 47. Caching the result of DB queries.
  48. 48. http://wordpress.org/extend/plugins/db-cache-reloaded-fix/
  49. 49. Cache the whole ofWordPress’s outputs.
  50. 50. http://wordpress.org/extend/plugins/wp-super-cache/
  51. 51. http://wordpress.org/extend/plugins/nginx-champuru/
  52. 52. Tuning up MySQL
  53. 53. $ wget mysqltuner.pl$ chmod +x mysqltuner.pl$ ./mysqltuner.pl
  54. 54. Twitter : @wokamoto

×