Speed of website loading has become one of the crucial parameter for user experience and search ranking also. There can be several ways to speed up WordPress by either introducing high cost dedicated server/ VPS servers or using some alternate methods for low cost solution.
My focus is to present low cost solution to users as WordPress is mostly used by personal bloggers who don’t want to spend for high end solutions. Larger number of WordPress installations are on shared hosting platform which have certain reservations due to sharing of resources like server bandwidth, RAM etc. So our purpose is to overcome these limitations and speed up WordPress.
First, we are aware about the use of CDN for improving loading speed of website. Let us see basics of CDN operation. In general, each webpage has html/text file which contains the links for associated resources like CSS file, JS files, images etc. So whenever any request goes to server then it first fetch its html file and then other resources are also collected. The html file is dynamically generated by WordPress installation. If you are using some cache plugin or performance plugin like W3 Total cache then those plugins cache html and other things for each page. Caching of pages help to reduce load on Server. Whenever any page request is there, then WordPress will check availability of cached html otherwise it will dynamically generate html for the request.
The other static resources which are linked in html page are then collected by browser for creating a complete webpage. The html content has to be generated/delivered by server where WordPress installation exists but static resources can be delivered by other servers also. This is the main objective for using CDN. If you change the links of static resources in main html file then those links will point to other server. In case of CDN, the linking url of those static resources points towards CDN server. This helps us in reducing load on primary server. Out of total resources for webpage, only few files are transferred from primary server, rest are delivered from CDN servers.
CDN servers has lot more technology to deliver your content /static resources from your nearest location with fastest speed. So the delay created by primary server for delivering each static resource is removed by use of CDN.
Now we just assume that our static resources are delivered by CDN with best performance. But in spite of this there are components which introduce delay in loading webpage. We know that static resources are delivered by CDN but html page is still supplied by primary servers. Downloading of Static resources start after this html is downloaded by browser. So the delay in loading this html file affects overall response of webpage critically. In shared hosting environment, the server connection time, wait time, receive time etc is significant. You may see cases where this html file transfer itself takes more than a second.
Next, our objective is to reduce transfer time for this html file. If we deliver html file also from CDN server then we can improve the overall response of webpage loading. As we discussed above about caching of pages so that WordPress need not generate each page dynamically for each request. These cached pages reside in primary server. If this cached html is delivered from CDN server instead of primary server then our purpose of loading everything from CDN will be fulfilled.
There is some problem with this system. We just want that our articles and other static pages get delivered totally by CDN. There are certain areas which should deliver dynamic content every time like login page and all backend administration area etc. So we need to cache html for certain pages and bypass caching of html for backend and login pages.
Speed up WordPress with Cloudflare
- Add your site for Cloudflare CDN
- Create page rules for Cache Everything with Cloudflare
Add your site for cloudflare CDN
There are lot of help materials for setting up Cloudflare CDN for your site. You can also refer earlier article How to setup Cloudflare CDN for WordPress.
Create page rules for Cache Everything with Cloudflare
One of the important thing to know that generally CDN cache only static resources like js,css and image files. Cloudflare also do the same. If you want to cache html resource also then you need to create page rule. Cloudflare has feature to create multiple page rule for caching of content. Free Cloudflare account allows only three page rule. But WordPress users can optimally utilize these three page rules to delivery of all content from Cloudflare CDN and speed up WordPress site.
After you add your site in Cloudflare, then go to pagerule section and create these three page rules. Create them in the same sequence as mentioned as priority of rules depends in the order they are recorded.
With pagerule specific CDN settings for particular url pattern can be created. Here we have three url pattern which can solve our purpose of html cache of pages except admin areas. The asterisk * before and after in url pattern allow any pre and post url pattern segment.
- The first pattern is to bypass cache for wp login page. You can also add something like *yourprimarydomain/wp-login* . In case of findurlaptop, wordpress installation is inside tech folder so all url have findurlaptop.com/tech pattern. If your primary domain directly points to WordPress installation then you can have url pattern like *yourprimarydomain/wp-login* otherwise you can also do like findurlaptop installation.
- Second pattern is to bypass cache for admin area
- Third pattern is to allow everything in your WordPress installation.
There are number of settings in each page rule but first and the most important is custom caching. First two pagerules bypass cache and third pagerule allows to cache everything.
So this way you can achieve serving of complete WordPress page from Cloudflare CDN. This will significantly speed up WordPress.