interactive. media. development.

Showing posts with label speed up. Show all posts
Showing posts with label speed up. Show all posts

Solved: Wordpress Website Is Loading Very Slow - What to do?

If you ever had any issues with WordPress running very slow and people calling you to tell you they cant see your website, you may not be the only one. WordPress is a such a great frame work but its code complexity does not cooperate well with some servers.

We had a client come to us last week and asked us to analyze their WordPress based website as it was acting very slow. Our initial approach was to dig in and see the back-end first before making any changes. We did find some unnecessary plugins that were taking a tall on the load time but was not very significant however that always helps. After other tweaking and code optimization we decided to move their content, images, javascript, CSS files to content deliver network (CDN) for faster loading. And that did it, the site load decreased by 3.9 seconds. We also did some MySQL database optimization which had so many unused tables that were inserted by previous plugins even though they were un-installed the tables were still there. This happens quite a bit especially for sites that have had WordPress since the early days and the framework wasnt as advanced as it is today. If you need any help with speeding up your WordPress site please drop us a line and we will be happy to help you. 

Speed Up Website By Enabling MySQL query_cache

speed up mysql
If you have a large MySQL database with high traffic and too many queries are loading the best thing to do is enable "mysql query caching".

In order to enable the MySQL query cache, you will need to set some variables in mysql configuration file which in most cases is called my.cnf but not all server have it enabled so you will have to either create a new one or copy existing .cnf files.

Usually located under any of these directories:

/etc/my.cnf
/etc/mysql/my.cnf
$MYSQL_HOME/my.cnf
[datadir]/my.cnf
~/.my.cnf

If you can't find it there then move try running a shell command locate  my.cnf and what this does is look for that file so your can find the location and edit it but if it does not return any results you can try and see if any of the following files exist:

my-medium.cnf
my-small.cnf
my-large.cnf

Most likely one of them will return so just copy the my-medium.cnf(for normal or medium size databases) file to the /etc/ directory and rename it to my.cnf

Now open up your newly created my.cnf file (command  vim   my.cnf )

That will open up the following file but **note that this is on a localhost so the configuration file might be different on your server.

Sample MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /Applications/MAMP/db/mysql) or
# ~/.my.cnf to set user-specific options.
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /Applications/MAMP/tmp/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /Applications/MAMP/tmp/mysql/mysql.sock
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M


#added for query cache (added)
query-cache-type = 1(added)
query-cache-size = 10M(added)


# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
"/Applications/MAMP/Library/my.cnf" 158L, 5018C


Now you will need to enable the query_cache by just adding these two lines of code :

query-cache-type = 1
query-cache-size = 10M

or if that does not work try this :

SELECT SQL_CACHE field1, field2 FROM table1 WHERE field3 = ‘yes’

And to check see if your mysql server has enabled query cache, simply run this query:
SHOW STATUS LIKE ‘%qcache%’;
a result similar to this will show up:

+————————-+———-+
| Variable_name | Value |
+————————-+———-+
| Qcache_queries_in_cache | 1 |
| Qcache_inserts | 3 |
| Qcache_hits | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 2 |
| Qcache_free_memory | 20947592 |
| Qcache_free_blocks | 1 |
| Qcache_total_blocks | 4 |
+————————-+———-+

And you can adjust the settings as you see go along. Thats it!

If you have any questions or like us to set this up for you please contact us 




5 Tips to Speed Up Your Website

Studies show that people will abandon your website if it does not load in at least 4 seconds. Yes, now days online users are very impatient and will move one fairly quickly to another site.

Speed in my opinion is the second most important aspect after search engine optimization which gets people to your site. Lets say you have optimized you site very well and and you are getting quite a bit of traffic but once people get there and wait its of no use.

So here hare some useful tips to boost your website speed:
  1. Get a dedicated server with at least 1GB of RAM
  2. Enable MySQL query cache for website with lots of queries
  3. Serve images, JavaScripts, CSS files form a cookieless domain or CDN
  4. Use less code in your pages and dont clutter it with unnecessary applicatons you dont need. Simple
  5. Scale images so the browser does not have to do it and determine the size. Less steps for the browser the better it is for you. 
There are plenty other speed factors but these are some good ones to get you started. If you need any help please feel free to contact us.



How to Speed Up & Optimize Your Website The Best Way You Can

First thing that any website owner has to keep in mind is SPEED. Optimizing your site so that it loads in less than 5 seconds should be the main goal. Ever notice some websites that you land on but take forever to load and you hit the back but faster than the website loads! Well, thats not good. Your chances of having lost that customer are pretty high.

Most companies spend so much time and resources designing a top-notch website but fail to address one simple thing - page load. There is no point of having a great and useful website if it loads super-slow and people cant get to it. The average time a person spends on a page is about 8 seconds and if the site takes more than 10 seconds too load, that person is gone in no time without even waiting for it to load.

So what causes the webpage to load so slow ?

There are a few factors and it really depends on the websites structure bu the most common are:
  • Too many images that are not saved for the web (e.g banner.jpg 890 KB) 
  • Heavy usage of JavaScript 
  • Bad choice of web application platform ( e.g CMS, Shopping Cart, etc)
  • Server performance ( shared hosting, not enough RAM)
  • Poor coding structure that does not flow correctly
This is just the top of the surface and there are too many other aspects of website optimization and we cant list them all here.

Below are some quick tips for website optimization for and improve page loading times :
  1. Compress all of your scripts including all CSS, Javascripts files and externally reference them.
  2. Create a cookie-less subdomain and host all of your images there so you are not appending unnecessary cookies to the images. (Do the same for css and js files)
  3. Get a VPS server or Dedicated server with at least 712MB in RAM
  4. Separate your database from your local web server to a different server but make sure there is not latency. ( this one is complicated)
  5. Disable Apache modules that you don't need as Apache is memory hungry and will take up RAM
  6. If using php add application accelerators such as xcache, eaccelerator, zend
Optimizing your website for faster page load is an ongoing process that requires a lot of work but that its worth it at the end because FASTER website equals more customers which leads to more revenue.

If you can't do this on your own and are looking to hire a developer to do instead, please email me at don@tripleroi.com to discuss the details.

© Copyright Triple ROI
165 Tremont St Boston, MA 02111 - Suite 3

Terms of Use | Privacy Policy