Archive

How to Speed up Your Site via Cloudflare Page Rules for HTML

HTML is one of the most important aspects with regard to the speed of your webpages. If we cache HTML it will reduce the usage of resources and improve the performance of the site. Caching HTML is very useful in a site performance perspective. You know that Cloudflare usually caches all static resources which has also a great impact on site performance. Like CSS, Javascript, images, and all. But what about HTML?, so in this article, we are going to explain how to make HTML caching work with WordPress and Cloudflare Page Rules

HTML caching is called full page cache it is not a default cached code from the Cloudflare we have to create rules for this. So what we need to do so let see.

Required Features for HTML full page caching

Page Rules

As I already stated above that by default, Cloudflare is not caching HTML. to do so we need to use page rules and have to enable the cache everything setting. This means you enable the caching of HTML by making a rule that cache everything. But to do this there is a problem and you have to take care of these two factors while making page rule for HTML.

  1. The HTML content for which you are creating the rules has to be static. In simple words, it does not change over time. Like a dynamic front page.
  2. The second thing the content is anonymous. This means that it is the same piece of content that is intended for any visitor to this resource.

These all thing shows that Caching everything is not engough for the setup.

Cache Everything

Cache Everything means you cached everything even the content not needed to cache. When you cache everything this will be a risk. Maybe you cache those content that is not intended for the next visitor. Let me explain with an example if you are login as an admin in WordPress dashboard and visit your front page and you cached everything, literally everything. Then the next visitor who is a normal visitor who accesses the site will see the admin edit bar that only was intended for you. So to not get stuck in this type of stuff you need to do and other things and that is to Bypass Cache on the Cookie setting.

Bypass Cache on Cookie

A cookie is a small piece of data stored on the user’s computer by the web browser while browsing a website. To login to a website, cookies are needed to maintain a link between your local computer and server. A cookie from your local computer, it is sent with every request you make to the server. This means that you can tell the server to pass the request through to the origin server, given the user has a certain cookie. With this enabled, you can deliver cached responses to Anonymous visitors, while you as an Administrator, or a logged-in customer in your WooCommerce, are getting served a tailored HTML page that will not be cached. In this way you have to do so you will not face the everything cache problem.

Always chose a best and correct plan to do this.

Configure Cloudflare for HTML caching for WordPress

Caching HTML is one of the important and critical issues. Keep in mind that when you are going to leverage Cloudflare for the HTML caching, always reduce the number of plugins you are using for caching, Optimization, aggregation, and all that. The use of more plugins makes it complex and complicated. Made the thing harder to resolve and understand. maybe they also cause a conflict. And I honestly tell you that caching with Cloudflare is more efficient and worthy. There’s nothing more annoying than trying to debug cache issues on a CDN. A visitor would report some error, and when you test this hitting another CDN node the results could be entirely different.

Now its time to setup page rules for html. To do so follow the steps.

Setting up the Cloudflare Page Rules

In order to process the different requests from Cloudflare, you need to set up different rules for it. The first-page rule that matches the incoming request is the one that will be applied. 

To add Page rule go to Page Rule

image

Here is some configuration, These are some basic configurations for a WordPress site.

Cloudflare Page Rules

Explanation for these Cloudflare Page Rules:

Now let’s explain these rules we provided above. These three rules are different and have there own importance according to there values.

1: Enable Cache for all requests going to anything in the folder wp-content. And this rule includes all the themes and plugins all.

2: Now I think you got it for which contains the second rule is. Yes, it is for all requests from the wp-. This rule bypass the cookie. This makes it possible for you to log in wp-login.php, and work in the admin wp-admin/* without running into caching issues. When you log in to the Control Panel, you will get the no-cache cookie

3: This third rule is for the whole website. All the rest requests. I didn’t set the bypass cache on it you can set for this.

This is for a stranded WordPress site but for a woocomerce site you need some other rules as well.

Additional required Cloudflare Page Rules for WooCommerce:

As you know the woocomerce site is very different from the normal site and there is a huge difference between the caching of woocomerce and a normal blog site. Although the basic rules for woocomerce are the same it need some additional rules for this purpose. These rules are specified for specific paths of sites. Like checkout, cart, etc. I will show you some rules.

Cloudflare Page Rules

With the rule mentioned above, you can also use these two rules for your woocomerce site. The checkout often involves multiple steps, therefore the checkout wildcard rule is used to bypass the cache. and also the cart.

In this article, we will go for some other details but first, we have to know how we can purge cache in cloudflare.

Purge cache in Cloudflare

Purge meaning clearing cache in Cloudflare. Sometimes you need to clear the cache in order to visible changes and getting some new content. Purging cache is different in Free and Enterprise plans. I will discuss here the method. For the free version, we have Purge by single-file (by URL).

Purge by single-file (by URL):
  1. Login to Cloudflare
  2. Select the site you need to purge
  3. Go to the Caching from the top menu.
  4. In the Purge Cache pane, click Custom Purge.
Cloudflare Page Rules
  1. Select URL in the Purge by field.
  2. Enter the appropriate value(s) in the text box
  3. Perform any additional instructions to complete the form.
  4. Review your entries.
  5. Click Purge.
Cloudflare Page Rules

The purging for Enterprized is different from the free plan. Follow the guide to do so.

You can do more customization of Cloudflare Page Rules

Different sites need a different type of setup because they have a different type of requests. All sites are different, and there are usually certain paths and requests you’d like to exclude from caching. Both plugins and themes sometimes require customization. Also, API requests are generally not something you’d like to cache.

Including and excluding the content is specific for every site and you have to do it according to that specific site. there are some extra settings like Edge cache TTL, Browser cache TTL, Origin cache TTL you have to take care of these for caching.

Edge Cache TTL:

Edge Cache TTL is used to tell the Cloudflare how long to keep the asset in the cache. We can say that this is an edge of time to keep the data in the cache. Let say we want to keep the cache for a month or more then we set that limit for the cache. Usually, it depends upon you I mean the user. How long you are using the same content and when you want to change it. Read more about this here.

Browser Cache TTL:

Browser cache is special. You can set these using page rules. Unless specifically set in a Page rule, Cloudflare does not override or insert Cache-Control headers if you set Browser Cache TTL to Respect Existing Headers. It cannot be cleared by clicking a button. The only way to bypass the browser cache is to force-reload a page (which will make the browser reload the page from the server) or let it expire. The upside of the browser cache is that it is the cache closest to the users – so it will make HTML load in just fractions of a second because it doesn’t require any network traffic.

If you want to know more about it and want to know how to set up click here.

Origin Cache Control:
These are used for CND. These Cache-Control headers are one way for web administrators to tell Cloudflare how to handle content from the origin. This is a very nice feature for advanced users, that know how to manipulate headers and instruct the Edge cache using headers.

Read more about Origin Cache Control here.

How To Solve The Redirection Error Of Your Hacked Website And, How To Get Back Your Hacked Website

Follow US on Facebook / Twitter  for update.

How to optimize WordPress site using LSCache Plugin

Learn from Niel Patel as to why slow speed is a killer for your online business and let see how you can easily speed up your website.

WordPress is a free Content Management System (CMS) used by more than 60 million websites, WordPress is one of the most popular CMS solutions. Considering the popularity of this CMS, optimizing WordPress sites to load quickly is very important and sometimes it is difficult. PageSpeed of any website is one of the major factors for both usability and SEO. In this article, we will discuss how you can improve the loading speed of your WordPress site using LSCache Plugin.


Table of Contents

  1. What is PageSpeed or Page Optimization?
  2. Factors that affect the PageSpeed of a WordPress site.
  3. How to improve PageSpeed.
  4. How to check PageSpeed.
  5. Benefits of PageSpeed.

1. What is PageSpeed or Page Optimization?

Basically PageSpeed means that how quickly a web page load when a visitor clicks on the link or types in the URL. Usually, a visitor expects that their pages load quickly and this imparts a good first impression on them. PageSpeed not only creates a good impression but also improve search ranking as it affects the SEO


2. Factors that affect the PageSpeed of a WordPress site:

  1. Un-optimized media (Large-sized images and videos)
  2. Un-used CSS and JS
  3. Un-Minified CSS and JS
  4. Excessive Use of Plugins and Widgets (In-active and unnecessary plugins)
  5. WordPress Theme (Theme Choice is important)
  6. Poor Choice of Hosting Service.

3. How to improve PageSpeed:

Follow the steps mentioned below to improve overall speed of your WordPress site.

3.1 Optimize or Reduce media size:

Use of Images and videos make the content more beautiful and attractive but a common mistake is to upload pictures and video directly without any optimization. Always optimize media like videos and images before uploading it on site for use. Use the latest jpg/jpeg version only, PNGs should only be used when transparency is needed. Lower images result in smaller page sizes hence a boost to Pagespeed.

For the images that have been uploaded already, you can also use WordPress plugins for image optimization.

Most Common Image Optimization Plugins:

  1. LiteSpeed Cache
  2. Imagify
  3. Optimole
  4. ShortPixel Image Optimizer

There are many image optimization plugins on WordPress plugins directory, let see how we can use LiteSpeed Cache plugin to optimize images:

  1. Click on LiteSpeed Cache -> Image Optimization. 
  2. Click on Send for Optimization button until all the images are optimized
  3. Once optimization is completed click on Gather image Data.
  4. Check the Image information section on the right side, it shows the optimization status. Green ticks suggest complete optimization.
Image Optimization
  1. Go on the Image Optimization Settings Option on screen.
  2. Check all the options as shown in the picture.
Image Optimization

3.2 Minify HTML, CSS and JS Files:

Minification of HTML, CSS, and JS files are some of the most common and important steps to increase page speed.  Google PageSpeed Insights and/or any other page speed tool always recommends this.

This issue happens due to the white spaces and extra CSS and JS  on the website page.

You can fix these issues manually or use a WordPress plugin to do so. Some plugins are listed below.

  1. LiteSpeed Cache
  2. Autoptimize
  3. JCH Optimize

Minify CSS and JS using LiteSpeed Cache:

  1. Click on LiteSpeed Cache -> Page Optimization -> JS Settings
  2. Change your settings according to the image below
  3. Follow this guide in case this setting breaks any functionality or visual structure of your site
Js Optimization
  1. Click on LiteSpeed Cache -> Page Optimization -> CSS Settings
  2. Change your settings according to the image below
  3. Follow this guide in case this setting breaks any functionality or visual structure of your site
CSS Setings

3.3 Excessive Use of Plugins and Widgets:

Excessive use of Plugins and Widgets can also slow down your PageSpeed. Always take care of extra and unnecessary Plugins and Widgets. Uninstall all in-active and unused plugins from sites. Never add any unused widgets.

Delete extra/inactive Plugins

  1. Click on Plugins->Installed plugins -> InActive
  2. Click on the Delete option right below the plugin name
Uninstall Plugin

3.4 Theme Choice:

The choice of theme to run the site is very important. Always choose a lite-weight theme for your site. Unlicensed/nulled themes slow down PageSpeed of your site so always use a licensed theme for the site.


3.5 Choice of Hosting service:

Hosting service is one of the main reasons behind the low PageSpeed. To run a  site on a shared server may be good from a financial point of view but it usually fails to deliver good loading times on peak traffic hours. So always use a good web hosting provider for your site to achieve a better PageSpeed, SEO, and traffic.


4. How to Check PageSpeed:

There are many ways to check the page speed of any site. A lot of sites are there to check the Page Speed of any site. Google also offers a tool called Google PageSpeed Insights for this.

Some sites that can help you to check various factors affecting your PageSpeed:

How to optimize WordPress site using LSCache Plugin

5. Benefits of high PageSpeed:

  1. PageSpeed improves search engine rankings
  2. It is important for SEO
  3. It ensures a good first impression on the visitor
  4. Also, help to decrease the Bounce Rate so visitors love to navigate between pages

Read More: HOW TO CHANGE TIMEZONE ON LINUX SERVER

Follow US on Facebook / Twitter  for updates.