What is Caching and why use it?

What is Caching and why use it?

What is Caching and why use it?

  • 3 years ago
  • postat de: NSHOST

Cache is King! A heavy traffic to a website can lead to performance issues, slower page speeds and, of course, fewer conversions. The most important thing a site owner should do after launching a website is to make sure that a proper caching policy is implemented, which will speed up every page loading. 


Websites are generally viewed hundreds, thousands or sometimes even millions of times a month. Normally, every time a user requests a web page, the server has to do a bunch of complex (time consuming) calculations - generating templates, database queries to display articles, products, images / videos, titles, descriptions, interactions, etc. Even if, in many cases, the result of all these calculations will be exactly the same, the server resumes each step from scratch, each time. Practical caching runs all the steps once, directly displaying the result of all requests from users!


So, it's about storing the requested data for faster access later. Both the browser and the server create a cache for faster performance. There are two types of caching from the point of view of the 'responsible' memory: client-side caching (site caching or browser caching) and server-side caching.


A site cache (HTTP or page cache) is a system that temporarily stores data such as web pages, images, and similar media content when a web page is first loaded. If we talk about browser caching - the control of the cache is the browser used to load the page. 


A cache on the server stores a site similar to the kind of storage performed by most modern browsers (Chrome, Firefox, Opera, Edge, etc.), except that instead of temporarily saving client-side content, it is stored on a site's server The caching of the site is also completely managed on the server, without any involvement of the end user or a browser.There are several types of caching: 

  • object caching - which stores database queries in a memory fast recovery cache on the server for future similar requests

  • CDN caching - a group of servers that are geographically located around the world and cache content uploaded using the server closest to the end user for much faster load times

  • Opcode caching - PHP code is compiled between each request, then cached so that it can run faster on reloads. page patches


What happens when the content of a page changes?


Assuming you have a cached blog enabled. The first time someone accesses your homepage, they receive the page normally: the request is received, processed on the server, and the resulting web page to be displayed is transformed into an HTML file and sent to the visitor's web browser.


Because caching is enabled, the server stores this HTML file - usually in "random access memory" (or RAM), which is extremely fast. The next time you or anyone else views your homepage, the server does not need to process and convert to HTML. Instead, simply send the ready-made HTML file to the browser. If the previously displayed article has undergone image changes or other content, the site developer must ensure that it implements an appropriate caching policy so that the old content is deleted and replaced with new content.


As you get more and more traffic to your website, it can become too much for your server if everyone has to download every content component again and you risk spending increasing budgets to increase resources on your server.


Mobile devices are limited by bandwidth, with some mobile data plans limiting users in terms of both the speed and the amount of mb included in monthly paid plans. The more cached a website is, the less data the user will use to load the same webpage. Mobile performance is the key to a brand's success. 

We encourage you to invest in an optimal hosting plan - choosing any of the NSHOSThosting packages VPS or Cloud and allocate the time needed for a caching policy that suits your business.