• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

optimize

Caching With Widgets

September 24, 2012 by Webhead

W3 Total Cache is a great WordPress plugin that will help your Google Page Speed score and will also speed up your website.  The only problem is that it doesn’t clear the cache when widgets are updated.  So for example if you have a custom theme with a widget on your page and you update this widget, changes are not going to be seen.  You’ll have to empty the cache on the W3 Total Cache page.

WPEngine also has a caching system that doesn’t clear the cache upon editing widgets.  This means that every time you update a widget you have to manually clear the cache.  WPEngine is a great WordPress host, but doing something manually isn’t good for clients.

A solution is to add a function to clear the cache every time the widget is updated.  The code below covers W3 Total Cache, WP Super Cache and WPEngine.  You can copy-paste it into your functions.php or just install the Clear Cache For Widgets plugin.

function clear_cache_for_widgets( $instance ) {

// if W3 Total Cache is being used, clear the cache
if ( function_exists( 'w3tc_pgcache_flush' ) ) {
w3tc_pgcache_flush();
}
// if WP Super Cache is being used, clear the cache
else if ( function_exists( 'wp_cache_clean_cache' ) ) {
global $file_prefix;
wp_cache_clean_cache( $file_prefix );
}
else if ( class_exists( 'WpeCommon' ) ) {
WpeCommon::purge_memcached();
WpeCommon::clear_maxcdn_cache();
WpeCommon::purge_varnish_cache();
}

return $instance;
}
add_filter( 'widget_update_callback', 'clear_cache_for_widgets', 10 );

Source: http://scratch99.com/wordpress/development/clearing-cache-when-widget-saved/
http://wordpress.stackexchange.com/questions/25425/page-cache-for-categories-not-updating-with-w3-total-cache

Filed Under: Coding, Plugins Tagged With: google, optimize, php, wordpress, wpengine

MAMP optimizations

May 18, 2012 by Webhead

“Optimizations” in the sense that you’ll have to do less work.  This website gives some great tips on saving you some time using MAMP.

http://www.sitepen.com/blog/2008/05/16/supercharge-mamp/

This site below actually helped me with the silent MAMP startup.  Read the comments on this page for updates on getting it to work with version 2.  It’s so good to not deal with the GUI and entering my password!

http://stringfoo.com/2008/08/25/tutorial-launching-mamp-silently-on-startup/

 

The 2nd website no longer exists and I’m afraid the first one will be gone.  Below are the steps required to start MAMP 3.x without the GUI automatically on startup:

  1. Use Standard Ports
    • Set the web port 80 and and MySQL port to 3306 by using the MAMP GUI preferences.  There’s even a button to set it so you don’t need to type it.
  2. Set up Virtual hosts (optional)
    1. Create the directory /Applications/MAMP/conf/apache/vhosts
    2. Open /Application/MAMP/conf/apache/httpd.conf and add this to the end:
      1. NameVirtualHost *:80
        Include /Applications/MAMP/conf/apache/vhosts/*.conf
    3. Restart Apache
      1. sudo /Applications/MAMP/bin/apache2/bin/apachectl restart
  3. Run MAMP at startup without having the GUI popup.
    1. Put the following in /Library/LaunchDaemons/USERNAME.mamp.start.apache.plist  replace USERNAME with your username in both the filename and the contents below.
      1. <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
         <dict>
         <key>Disabled</key>
         <false/>
         <key>Label</key>
         <string>corey.mamp.start.apache</string>
         <key>ProgramArguments</key>
         <array>
         <string>/Applications/MAMP/Library/bin/apachectl</string>
         <string>start</string>
         </array>
         <key>RunAtLoad</key>
         <true/>
         </dict>
        </plist>
    2. Create /Library/LaunchDaemons/USERNAME.mamp.start.mysql.plist  replace USERNAME with your username in both the filename and the contents below.
      1. <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
         <dict>
         <key>Label</key>
         <string>USERNAME.mamp.start.mysql</string>
         <key>ProgramArguments</key>
         <array>
         <string>/Applications/MAMP/Library/bin/mysqld_safe</string>
         <string>--port=3306</string>
         <string>--socket=/Applications/MAMP/tmp/mysql/mysql.sock</string>
         <string>--lower_case_table_names=1</string>
         <string>--pid-file=/Applications/MAMP/tmp/mysql/mysql.pid</string>
         <string>--log-error=/Applications/MAMP/logs/mysql_error_log</string>
         </array>
         <key>RunAtLoad</key>
         <true/>
         <key>UserName</key>
         <string>corey</string>
         </dict>
        </plist>
    3. Change the file permissions using the following commands:
      1. sudo chown root:wheel USERNAME.mamp.start.apache.plist
        sudo chown root:wheel USERNAME.mamp.start.mysql.plist

 

Filed Under: Coding Tagged With: apache, linux, optimize

Slow Javascript in IE

June 30, 2011 by Webhead

Problem:

The menu on this website:  http://www.sohtanaka.com/web-design/side-navigation-tooltip-popup-bubble/ ran fine in IE.  It was quick and worked fine.  On my website however, it ran slooow.

Solution:

Look for large images that may be loaded.  IE doesn’t seem to handle them very well.  The background image for my project was 1196×1150.  Pretty large…  Gotta adjust for the weakest browsers.

Filed Under: Coding Tagged With: IE crap, javascript, jquery, optimize

Image Optimization

June 7, 2011 by Webhead

Some great tools for optimizing images so that it downloads faster:

http://www.webdesignbooth.com/12-really-useful-image-optimization-tools-for-web-designers/

Filed Under: Off the Shelf Tagged With: optimize

VARCHAR vs TEXT Performance

May 21, 2011 by Webhead

Ever wonder if VARCHAR(255) or TEXT is a better data type?  This thread suggests VARCHAR(255) is better because it is allowed to use MEMORY (or RAM).  The TEXT data type is not allowed in there.

http://forums.mysql.com/read.php?24,105964,105964#msg-105964

 

Although it was also found that a larger VARCHAR like VARCHAR(3000) has worse performance than TEXT (in MyISAM).

http://nicj.net/2011/01/20/mysql-text-vs-varchar-performance

 

The general rule appears to be to use VARCHAR if it is less than 255 characters and to use TEXT if it’s 255 or more.

Filed Under: Coding Tagged With: mysql, optimize

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization macOS mac os x ms sql mysql open source optimize php php 7.2 rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools
  • Uncategorized