TechTipsApp

Technology tips blog

  • Articles
    Categories
    • Tech news
    • Internet
    • Social Network
    • Google
    • Geeky Tips
    • Android
    • Windows 10
    Top Posts
    • Install Windows XP from USB
    • Install Windows 7 from USB
    • Open Facebook When It's Blocked
    • Partition Hard Drive Without Formatting
    • Reset Windows 7 Password
    • About
    • Contact
    • Privacy policy
    • Advertise
    • Terms of Conduct & Copyright Policy

How to Configure MaxCDN without Any Plugin in WordPress

Tanmay WordPress Leave a Comment

MaxCDN is a reputed content delivery network (CDN) service which lets you serve images and other static files from different servers in different locations across the world. This reduces the page load time significantly and improves the search result ranking.
MaxCDN is cheaper and easy to configure with all types of website platforms including the WordPress. They provide a detailed step-by-step guide to set up its CDN service with your blog. You need to create a PULL zone at MaxCDN admin panel and install either W3Total Cache or WP Super Cache at your WordPress blog. There should not be any problem in configuring your CDN with WordPress through those plugins. But what, if you want to configure MaxCDN with your WordPress blog without any plugin?
Recently, I decided to purchase MaxCDN for our blog TechTipsApp.Com to serve images from a subdomain. After going through the setup process at MaxCDN admin panel, I needed to install any one of the above cache plugins. Here the problem raised for me.
configure maxcdn without wordpress plugin
This blog is hosted on SiteGround, a reputed web hosting service. It is the only web hosting company which provides Memcache service with the shared hosting plan. It also has 3 layer caching service which gives you a better performance.
SiteGround has its own caching plugin which is configured according to their servers. They always recommend to use their own caching extension to get the better performance than this by other caching plugins like W3TC or WP Super Cache. And it happens what they say.
As I was already using the SiteGround’s cache plugin, installing anyone of the the above cache plugins could conflict with each other. I contacted with the MaxCDN support and they told me that there is no way to use its service without having those plugin installed with the WordPress. I was just upset as I’ve already paid for the MaxCDN plan. Then I contacted with the SiteGround support team and described the whole thing. After taking a while they still recommended their own plugin SGCachePress and advised to avoid using other cache plugins. They also suggested not to use both SGCachePress and W3TC / WP Super Cache at the same time. So, I had two choices:

  1. Compromising with the caching performance and using the third party cache plugin to use MaxCDN
  2. Not using the MaxCDN.

But I wanted both. After going through some testing phases, I found out a very easy way to use MaxCDN service in WordPress without any plugin.

How to Configure MaxCDN in WordPress without any Plugin

All you need to do for this tricky tweak is changing the media setting at your WordPress admin panel and running a simple SQL query at your WordPress database. Here is how to do that.
Login to your WordPress admin panel and expand the ‘Settings’ option from the left sidebar and click on the item ‘Media’. Up to WP version 3.4, this settings page used to allow you configuring the default uploading path and the image URL path. But from the WP version 3.5, this feature has been withdrawn. I don’t know about the exact reason behind that but you can still bring back that feature at your current WordPress version by using this simple plugin.
Once you installed that plugin, you can see the options for changing the uploading path and the full URL path at the media settings page.
wordpress-media-settings
Now, notice that the ‘Store uploads in this folder’ filed is like this: wp-content > uploads, keep the default uploading path as it is. The MaxCDN automatically caches the contents from that directory. What you need to change here is the ‘Full URL path to files’ field. Just replace the domain name with your subdomain(MaxCDN pull zone).
modified-wordpress-media-setting
Once you complete the modification, save the settings and you can then uninstall the plugin. Don’t worry, the settings you’ve done won’t be removed until you completely make the fields empty.
Now, whenever you upload any image or file using the WordPress media uploader, it will be uploaded at the ‘uploads’ directory and the source path will be replaced with the URL that you mentioned at your media settings page. It means that the images will be served through the subdomain which is hosted by MaxCDN.
To serve the old images from the subdomain hosted by MaxCDN, go through the following workarounds.
Open phpMyAdmin from your hosting cPanel and select the database. Now, click on the SQL tab and run the following queries.

UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/wp-content/uploads/','http://cdn.yourdomain.com/wp-content/uploads/')
UPDATE wp_posts SET guid = REPLACE(guid,'http://www.yourdomain.com/wp-content/uploads/','http://cdn.yourdomain.com/wp-content/uploads/')

Don’t forget to replace ‘cdn’ with your own subdomain. You are done! All the images are now served from the subdomain via MaxCDN.
Have any thing to add to this story? Do share with us at the comment section.

Post Tags: MaxCDN, Performance, Plugin
Similar Articles from This Blog
Host Images on Subdomain for WordPress Blog
Host Images on Subdomain for WordPress Blog
DU Speed Booster Review: A Necessary App to Make Your Android Faster
DU Speed Booster Review: A Necessary App to Make Your Android Faster
Auto Refresh Twitter Page for New Tweets
Auto Refresh Twitter Page for New Tweets
Install Contact Page in WordPress Blog Without Any Plugin
Install Contact Page in WordPress Blog Without Any Plugin
How to Track Software Usage on Windows
How to Track Software Usage on Windows
How to Speed Up USB Data Transfer Rate in Windows 7
How to Speed Up USB Data Transfer Rate in Windows 7

Comments

  1. Evan :

    Thanks for this writeup. I just signed up for media temples managed wordpress hosting. They have a blacklist of plugins, which includes ALL the popular caching plugins. They do not provide a custom caching plugin of their own however.
    I am going to attempt this method when the time comes to flip on the CDN.
    Thanks!

    Reply
  2. Evan :

    I just realized that this article specifies images only. How would one go about serving .js and .css files from the CDN??

    Reply
    • Tanmay Ahmed :

      They just need to edit the source of the CSS and JS files at the templates and replace the local address with the CDN address. Hope this will help.

      Reply
  3. Brett :

    Amazing tutorial. I had the EXACT same problem as I’m using MediaTemple’s Premium WP hosting, they have their own internal caching and could not come up with a viable solution until I read this. Going to give this a try.
    One thing I would suggest changing in your post. On your update statement you had
    UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/','http://cdn.yourdomain.com/')
    I would strongly suggest changing to this
    UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/wp-content/uploads','http://cdn.yourdomain.com/wp-content/uploads')
    Your current update statement would also update any internal links. By changing to above it would only apply to image directory instances only.

    Reply
    • Tanmay Ahmed :

      Thanks for the notification. Updated it into the article body.

      Reply
    • Jack :

      Forgive me, I’m just trying to understand the difference between the two querry’s that have been suggested before i do anything crazy. 🙂
      I see where Brett suggested a different querry, but I don’t understand why.
      Brett said “Your current update statement would also update any internal links.”
      – If someone had existing images (like most of us do), wouldn’t it be best to update the image urls? Isn’t that what most people would want?
      He also said “By changing to above it would only apply to image directory instances only.”
      – When you say “changing to the above” are you talking about Bretts querry, or your own?
      Thanks to both of you, I just need to be sure which querry’s to run in order to update the urls to http:cdn.mysite.com

      Reply
      • Tanmay Ahmed :

        Actually, I did the mistake. I wrote this query UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/','http://cdn.yourdomain.com/' at first by mistake. This will modify all the urls into the post content including the image source path also. Suppose, you have a link in your post, say, https://www.techtipsapp.com/contact/ . And you also have an image whose source path is like this: https://www.techtipsapp.com/wp-content/uploads/image.png. With the code written by mistake would modify both the urls. But the modified code which is currently in the article body will only change the path for the image. Not other urls.

        Reply
  4. Pranjal :

    Howdy Tanmay,
    Thanks for an alternative solution to the issue.
    Recently, I had also transferred my site to Siteground, and in my case I was using Amazon Cloudfront. So, after few discussions with Siteground support they asked me to reach Amazon for the help but, instead I tried to Google the issue.
    Lately, I found this plugin called CDN Linker, and it worked with little to no configuration. I had written a handy guide here on how to use this free plugin.
    http://www.blogosense.com/configure-cdn-wordpress-withtout-w3-total-cache/
    Hope you found it useful 🙂

    Reply
    • Tanmay Ahmed :

      Thanks Pranjal for the information. Actually, I always like to avoid plugins if I could manage to configure my WordPress manually. However, nice write up.

      Reply
  5. Chris :

    I did this But need to Reverse it to slow siteground that it is not a CDN issue I’m having!
    How to find those 2 files in and delete??
    Thanks so much!

    Reply
    • Tanmay Ahmed :

      Can you please mention the name of the files you want to find and delete?

      Reply
      • Chris :

        It was the 2 files you have here that we copied and pasted in sql but changed to our cdn link. It simply would be what you wrote but “adding a way to undo the sql entries” to make this a complete tutorial 🙂
        UPDATE wp_posts SET post_content = REPLACE(post_content,’http://www.yourdomain.com/’,’http://cdn.yourdomain.com/
        UPDATE wp_posts SET guid = REPLACE(guid,’http://www.yourdomain.com/wp-content/uploads/’,’http://cdn.yourdomain.com/wp-content/uploads/’)
        They worked as you wrote but simply need to undo for now.
        Thanks for your time and help!

        Reply
        • Tanmay Ahmed :

          Seems you are talking about the two queries not ‘2 files’. Well, if you want to revert back then swap the position of the URLs into the SQL queries. For instance, if you ran the first query – UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/wp-content/uploads/','http://cdn.yourdomain.com/wp-content/uploads/') then just run the following to revert back : UPDATE wp_posts SET post_content = REPLACE(post_content,'http://cdn.yourdomain.com/wp-content/uploads/','http://www.yourdomain.com/wp-content/uploads/').
          For the second one – UPDATE wp_posts SET guid = REPLACE(guid,'http://www.yourdomain.com/wp-content/uploads/','http://cdn.yourdomain.com/wp-content/uploads/') , run the following to revert : UPDATE wp_posts SET guid = REPLACE(guid,'http://cdn.yourdomain.com/wp-content/uploads/','http://www.yourdomain.com/wp-content/uploads/').
          Also reset the ‘Full URL path to files’ under the Media Settings (just keeping the field blank will do the job). Hope it helps you. Thanks you for dropping it here. Have anything more where we can help you out?

          Reply
          • Chris :

            Thanks you for your detailed ‘reversal’ help!!

  6. Dave :

    Is this possible to use multiple cdn nodes like cdn1.subdomain, cdn2.sub.., cdn3.sub.. and so on to further speed up the fetching process and how?

    Reply
    • Tanmay :

      Yes, you always can. You just need to create different zones and assign different subdomain for them and use them in your site accordingly.

      Reply
  7. Russell Strange :

    Works like a champ! Thank you for the information.
    I would add one more tidbit…
    Be sure to change your “UPDATE wp_posts SET” to “UPDATE your_prefix SET” if you have changed your wordpress prefix in the DB.
    Cheers

    Reply

Leave a Comment Cancel reply

Your email address will not be published. Required fields are marked *

About Us

Tech Tips App is a technology blog, looking forward to broaden the mental horizons of technical geeks round the web. Striving hard to quench your technical thirst, we have put our best efforts on the line of exhaust to satisfy your versatile technical vocabulary.

Recently Published

  1. Partitioning Hard Drive in Windows 7 Without Formatting
  2. How to Find My Contacts on Google Map
  3. Introducing SMS Organizer by Microsoft is the Best SMS App
  4. How to Fix Windows Update When It Gets Stuck
  5. How to Get Rid of Windows 10 Automatic Repair Loop [Solved]
  6. Best Antivirus for Windows 10 (Is Windows Defender Good Enough?)
  7. Best Facebook Messenger Bots to Get more out of Messenger
  8. How to Fax a Document From Your Smartphone
  9. Top Social Media Platforms You Should Always Know About
  10. Bitcoin vs Altcoin: Where to Invest? – Guide For Dummies

© 2021 Tech Tips App All Rights Reserved  Post Sitemap