{"id":813,"date":"2009-10-11T14:57:49","date_gmt":"2009-10-11T18:57:49","guid":{"rendered":"http:\/\/cd34.com\/blog\/?p=813"},"modified":"2009-10-11T14:57:49","modified_gmt":"2009-10-11T18:57:49","slug":"converting-to-a-varnish-cdn-with-wordpress","status":"publish","type":"post","link":"https:\/\/cd34.com\/blog\/scalability\/converting-to-a-varnish-cdn-with-wordpress\/","title":{"rendered":"Converting to a Varnish CDN with WordPress"},"content":{"rendered":"<p>While working with Varnish I decided to try an experiment.  I knew that Varnish could assist sites, but, it has never been easy to run Varnish on a shared virtual or clustered virtual host.  VPS or Dedicated servers are no problem because you can do some configuration.  However, in this case, I wanted to see if we could use Varnish to emulate a CDN, and if so, how difficult would it be for wordpress.<\/p>\n<p>As it turns out, WordPress has a particular capability built in that handles media uploads.  In the admin, under Settings, Miscellaneous, there are two values.  One that asks where uploads should be stored.  That path is a relative path under your blog&#8217;s home directory.  The second is the URL that points to that path.  In most cases you need to leave this blank, but, we can use that to point the URL for images to use the CDN.<\/p>\n<p>Settings, Miscellaneous<\/p>\n<p>Store uploads in this folder: wp-content\/uploads<br \/>\nFull URL path to files: https:\/\/cd.cd34n.com\/blog\/wp-content\/uploads<\/p>\n<p>Second, all of the images that have been already posted need to have their URLs modified.  Since I am a command line guy, I executed the following command in MySQL.<\/p>\n<pre>\r\nupdate wp_posts set post_content=replace(post_content,'http:\/\/cd34.com\/blog\/wp-content\/uploads\/','https:\/\/cd.cd34n.com\/blog\/wp-content\/uploads\/');\r\n<\/pre>\n<p>According to the Yahoo YSlow plugin, my blog went from a 72 to a 98 out of 100 with this and a few other modifications.   The site does appear to be much snappier as well.<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/scalability\/converting-to-a-varnish-cdn-with-wordpress\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>While working with Varnish I decided to try an experiment. I knew that Varnish could assist sites, but, it has never been easy to run Varnish on a shared virtual or clustered virtual host. VPS or Dedicated servers are no problem because you can do some configuration. However, in this case, I wanted to see [&hellip;]<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/scalability\/converting-to-a-varnish-cdn-with-wordpress\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[83,21,84],"class_list":["post-813","post","type-post","status-publish","format-standard","hentry","category-scalability","tag-cdn","tag-varnish","tag-website-performance"],"_links":{"self":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/comments?post=813"}],"version-history":[{"count":5,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/813\/revisions"}],"predecessor-version":[{"id":818,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/813\/revisions\/818"}],"wp:attachment":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/media?parent=813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/categories?post=813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/tags?post=813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}