Speeding up my site and a CDN

wordpress

#1

Hi guys,

I have been running my wordpress site for about 7 years but I don’t consider myself technically proficient. My focus has been on creating content. What I am trying to say is that some of these questions may seem basic or even stupid and for that I apologize.

Recently, the site has slowed down and had lots of 404 and 500 errors. I had made no changes to the site or its configuration. I didn’t contact support because I know that sometimes these things happen and they usually get better by themselves - and they have. The server response time was pretty slow, so perhaps another website on the same server was getting hammered or something.

Last November, I got hacked and that made me realize I needed to spend more time on the webmaster aspect. I have hardened my installation and am happy with the results. But now, this recent slow down made me realize that I need to address the site’s speed and optimization.

With that in mind I have some questions.

  1. I read that it’s better to server static media from a domain that doesn’t use cookies. It took a while to understand that “no cookies” is not a setting on a panel anywhere, just the idea of not adding files to a domain that would then add cookies to a visitors computer. I am happy to buy a new domain and serve media from there but how would that affect any CDN system I may purchase in the future? I mean, if my site is www.example.COM and my media is on media.example.NET (I plan to sue sub-domains for different types of static files) will I have to have both sites listed for CDN or will having the main site be enough?

  2. I need to reduce the number of CSS and JS files on the site. In theory that’s fine but my posts in some categories require different files. I can add all the CSS into one file but that means there would be a chunk that is only needed some time or I could use some sort of PHP IF statement. But which is faster? This I suppose depends on the extra size of the CSS. I don’t have the means to test both versions, so is there a guide somewhere? For example, if the extra CSS was 5K then it’s better to include it in the style.css but if it is bigger then the PHP IF solution is faster. Of course, I’ll be minifying and Gzipping everything.

  3. If I decide to go down the CDN route, how will I get WordPress to know that all my media is on “media.example.NET”? I don’t mean within the posts, which link to media, but for featured iamges and uploads etc? I will do a search and replace on the DB for the old and new paths.

  4. I’m worried that my wp_options table has become full of crap after testing so many plugins and themes. I am aware and have used the Clean Options plugin and it worked quite well, but what are your thoughts on me just importing a fresh wp_options table with default settings at “starting again”? I know I’ll need to add the plugins again and adjust the settings but it would give me peace of mind that everything is clean.

Final points:

I have removed as many plugins as possible and will have them re-written to call media from the new static server.

I am having a new theme created for me and this will allow me to add all my custom code slowly and carefully to amke sure it’s needed. After that I’ll pay a WP expert to do a code review to check I am doing stuff the most efficient way.

Is there anything else I should be considering to make sure the site is as fast as possible?

TIA


#2

Before you jump into a CDN and all that stuff, there are some very simple things you can do.

First, upgrade PHP :slight_smile: You’re running on PHP 5.2, which works, but it’s slower for a lot of people and uses more memory. If you go into the Manage Domain section of the panel and click the “Edit” button for your domain, there’ll be a menu on that page for “PHP mode”. Switch that to “PHP 5.3 FastCGI” (the one that’s currently marked as “recommended”), then click the “Change settings” button a bit further down. – https://panel.dreamhost.com/index.cgi?tree=domain.manage&

You can also turn on PageSpeed, which will compress (i.e. minify) your pages. Since you’re getting a new theme, I would actually suggest waiting till you do that to turn on PageSpeed, to make sure you don’t accidentally cache the wrong style sheets. Been there, done that. You can also use PageSpeed to compress your CSS and JS, because you don’t want to manually put them all in one file. Other than being a bear to keep up to day, you lose the dynamic nature of WP if you do that! Which sucks :slight_smile: I have some notes here: http://elftest.net/kick-pagespeed-up-a-notch/

Finally you’ve got CloudFlare already. You may want to use them for your CDN instead of a home-grown cookieless domain. http://www.cloudflare.com/features-cdn (IMO cookieless is overrated, and it won’t break your bank to not use it).


#3

The marketing spiel that CDN companies use about having content “closer” to the user is basically snake oil. The difference can be measured in milliseconds and often the extra DNS lookup offsets this minuscule “speed increase” anyway. It can even make things slower.

The perception of speed from an end-user perspective comes from being able to pump as many files down the pipe and into their browser as fast as possible; which means concurrently. It’s as simple as creating a sub-domain like images.domain.tld and serving your image files from there. You don’t need an external or extra physical server for this.

Make sure browsers are caching your js and css files and then combine away (they’re only downloading them once). If they’re megabytes big when combined then don’t bother - use the extra subbie method like static.domain.tld and have them served from there.

tl;dr : Concurrency = Speed


#4

@Ipstenu-DH
Thanks for the tips. I wonder if DH should email people on 5.2 and recommend they upgrade. I would never have thought to look there as I assumed DH upgraded me automatically.

I did try Cloudflare but it slowed my site down and made my 7z and rar files go screwy.

@sXi
Thanks for the reply. Yes, I have set my htaccess to tell browsers to cache the static files. I was under the impression that most browsers limit the number of concurrent connection from the same domain to 2 and they treat sub-domains as the same as the main domain meaning unless it’s on a different domain, sub-domains don’t speed up the process.

I also thought that because they will be part of the same overall domain they will send cookies.


#5

On the off chance that you’re looking at things like webpage speed tests that are run by Google et al, then be aware that the methods and algorithms they use are flawed due to generalisation in that resultant scores and tips are based entirely on percentage calculation results rather than actual pipe savings.

While the RFC on HTTP indicates that connections should be limited to 2, browser creators have long disregarded the spec since Opera devs decided years ago that users on high speed connections had suffered long enough from such a limitation. That said, the browsers developed by programmers who adhere to their engineer’s specifications (e.g. IE and Opera) will limit connections to 2 per server if they detect they are running over a dial-up connection.

Defaults that I’m aware of - IE8 6, IE10 8, Opera 6, Chrome 6 (hard coded, immutable), FF 6 (8 in recent versions).

I’d take a look at what’s loading /wp-admin/admin-ajax.php and get rid of it if possible. Your site will be instantly twice as “fast”.