Thursday, February 16, 2017

All You Need to Know About WordPress Caching

Every website owner knows that a fast loading website is an essential component to the recipe to online success. Every millisecond counts and can make a difference in the number of visitors on your site. Visitors are easily annoyed by slow loading websites, and hence may not stay on your site for too long. As a rule of thumb, if your pages take longer than 5 seconds to load then consider it an issue. Apart from spoiling the visitor experience, a slow loading website can also be a contributing factor for low ranking on a Search Engines.

speedThe importance of optimizing web pages and improving loading speed of WordPress sites is also highly stressed upon by the WordPress community. WordPress caching is the fastest and easiest approach towards the site's overall performance. In WordPress, the HTML pages are generated dynamically by combining the required PHP scripts and obtained data from MySQL database queries. WordPress caching basically speeds up the process by reusing the previously generated f etch data (or database queries) to satisfy the ensuing requests.

While you can also speed up WordPress sites employing a Content Delivery Network or bringing high end clustered servers into the mix, these options will cost you more money and their effectiveness is depending on the number of visitors on your site. In contrast, WordPress caching is an easier, less expensive alternative that can be employed on even the small-scale websites.

What Is Caching?

Cache refers to a place that temporarily stores data. When certain information or a website is frequently accessed, a cached version of it (containing a decent portion of the sites' files) is stored in the memory in order to reduce the loading time and other processing tasks.

What Is WordPress Caching?

To understand caching, you need to first develop an understanding of the flow of data from your site to the user. To browse a WordPress powered webpage, the visitor will need to request a lot of data from the WordPress host. Upon the visitor's request the WordPress core calls the required PHP script, queries the database and retrieves the data (including images, JS and CSS). Then, the WordPress core complies the fetched data and executes its PHP code for a dynamically generated HTML page to be returned to the user' browser. Since the HTML pages are generated dynamically, the WordPress core processes a new request for updated information for every visit. Most of the times, the cached version will do just fine as most pages on blogs do not change after publishing unless the website admin manually edits the posts.

Purging the Cache

Purging the cache basically refers to the act of re-caching the previously cached data in order to update it. This is usually necessary in the scenario when:

  • A someone comments on a post
  • A new post is published
  • Or an existing post is updated
  • It's the WordPress core and caching plugin's job to determine when there is a need to purge, so the cache do that the redundant data is not presented to the user.

    The Workings of Cache Plugins

    Cache plugins can provide a generous boost to your site loading speed by creating a static version of your site and serving a cached version of the page, the next time a visitor lands on your page. This reduces the processing time that would have been otherwise prolonged due to loading all PHP scripts for every refresh. Hence cache plugins help reduces site loading time for all future visitors. Many web development firms also offer their services to integrate cache plugins.

    Types of Caching

    There are two types of caching established on the principles of the client-server model, i.e. Client-side caching and Server-side caching.

    1. Client-Side Caching

    Websites have a lot of static data such as images, CSS files and JavaScript. Once a visitor visits the site and the static data is downloaded. Now even if you hit refresh, your browser will not re-download this data. Instead it will retrieve the static data saved in the local cache, which is stored on your computer's hard drive, and serves it to the user. That's precisely why people are advised to clear their browser cache only when necessarily needed, since it helps avoid redundancies (due to repeatedly downloading same data) as well as saves a lot of space and computing time. Since the cached data also results in lesser 200 responses (due to requests per page), hence client-side caching also reduces the load on server.

    2. Server-Side Caching

    Server-side caching refers to the various caching protocols as executed by your WordPress Server. They are as follows:

  • Page Caching: This is the simplest of all of the protocols mentioned above. It addresses the storing of each dynamically generated HTML page in the server's local storage, and serving the corresponding HTML file from the cache each time a request is made. This eliminates the need to execute PHP code and MSQL database queries to generate a full HTML page, each time a visitor lands on your website.
  • MySQL Database Caching: Databases are meant to store, update and serve data effectively upon request. It's not practical for WordPress to repeatedly make the same query to the database, in order to access the same posts for every visitor. Database caching saves the result of a single query to store in local storage and serves those results from the cache until the database is updated (i.e. when you update an existing post, a page, WordPress configuration options, or add a new article or someone comments). The old database cache is deleted, and the altering query results are re-cached.
  • Object Caching: WordPress contains its built-in object caching system which has several secondary-systems such as Caching API, Transient API and Object Cache.  It serves to cache some programmatic objects that are subsequently used by its memory. However, this sort of caching has a lifecycle of only one request. WordPress plugins can be used to control the object caching and hence reduce the number of requests.
  • PHP Opcode Caching: PHP files must be obtained from PHP pages by compiling it into code that can be executed later. Opcode caching stores the compiled PHP code between requests. This reduces the amount of processing the server has to go through as well as its' response time.
  • Conclusion

    Loading speed of your website is an important factor in determining your overall website performance as well as visitor experience, and can play a key role in boosting your search engine rankings. Therefore, it is very important you make the most of the WordPress caching and the available plugins. Your level of success will differ depending on your hosting plan, WordPress caching plugin configuration, the type of content on your page, etc. However, the only way forward and for your site to succeed online is to keep on testing different approaches and seeing what works for you. In time, you will surely find the recipe to success for your combination of content, hosting services and available resources.

    Author Bio:

    Asad Ali is a dynamic internet marketing expert and eCommerce guru associated with GO-Gulf Dubai – a web development firm where he has proven his success in creative SEO strategy, conversion optimization and user experience.

    Manish

    Manish Patel is an enterprenuer and internet marketer. He loves to write about WordPress including WP themes, plugins and various tweaks.

    Latest posts by Manish (see all)
    Source: All You Need to Know About WordPress Caching

    No comments:

    Post a Comment