Firstly, sorry for the click-baity title, but I do believe that this tip has the potential to change your WordPress experience for the better and it’s something that doesn’t seem to get talked about a lot by people recommending things to increase your page speed.

WP_MEMORY_LIMIT

People always talk about making sure you have a caching plugin like Litespeed, Total Cache or WP Super Cache and make sure you minify your javascript and CSS and that you have image optimising software on there so you can squash your images to nothing and they look good, but practically no one talks about making sure that you have allocated enough memory to your WordPress install as a thing to increase page speed.

Maybe they think that it’s so obvious it doesn’t need saying, but it’s a massive part of giving your website the best chance of loading as quickly as possible and it can be executed very easily. You just add define( 'WP_MEMORY_LIMIT', 'xxxM' ); to your wp-config.php file and that’s it! You just need to replace xxxM with whatever amount of memory you choose to use.

How much memory do I need?

This is a tricky question to answer as no two WordPress Themes seem to be the same but bascially, the more you can give it, the better. The general consensus seems to be 256M is the highest you should need to go and most themes ask for somewhere between 64M and 128M so that they run properly. You might want to go higher so that you can safely run plugins on top of the theme but most installs I have seen seem to run around 80M with a decent number of plugins installed.

How do I see how much memory I have allocated?

Good question! There are a few ways to do it but the easiest I’ve found is by adding a plugin like Server IP & Memory Display. I like this one as it’s really lightweight and adds a small sentence of code to the bottom of certain pages to show you what your server details are, how much memory is allocated and how much you are using and also what php version you are running.

Wordpress memory limit

As you can see, the limit that is showing here is way below the recommended amount and so we need to add the code to the wp-config.php file to increase this. The easiest way to do this is to use an FTP program like Filezilla or Cyberduck to pull your file from the server. Then add the define code I showed you above to the bottom of the file, just above “/* That’s all, stop editing! Happy blogging. */”

Wordpress memory limit upgraded

Now you have a site that’s getting as much memory as it can handle and you should notice an increase in your speed. If you don’t, then it’s likely that your site was not that big to begin with and didn’t need that much memory to run. If you don’t think that that is the case, then you can try the following.

Alternate ways of increasing WordPress memory

Now if you can’t get your memory limit to increase this way, you may need to have a chat with your hosting provider as they might have restricted control of this particular part of the WordPress program so that they can make sure people don’t go crazy with their memory allocation or some such thing. Also there are other ways to do it including:

Editing your php.ini file.

If you have access to this file (and you may not depending on whether your hosting company allows this), you can add the following code:

memory_limit = 256M ; Maximum amount of memory a script may consume (64MB)

Editing your .htaccess file

Again, if you have access to this file, then you can add the following code:

php_value memory_limit 256M

Woah Nelly!

Whatever way you need to use to get your memory allocation increased, you should now find that your site is loading way faster than it was before. This, plus all the usual caching plugin stuff I mentioned at the beginning of the piece, will help get you looked at more favourably by Google, Bing et al.