what is caching ? and how does it work ?
Your website’s performance is incredibly important. A fast site is key for providing an excellent user experience, while a slow site is often a factor in a loss of traffic. So what is Web Caching? And how can you use to improve performance and decrease loading times
What is web caching?
Web caching is storing data for in a server for future reuse, such as a copy of a web page served by a web server.
data is cached or stored the first time a user visits a page on your website and the next time a user requests the same page, a cache will serve the copy, which helps keep the origin server from getting overloaded
But what if my content changes?
A caching system doesn’t just consist of storing prepared HTML files, it also has a way to empty the cache (and then regenerate it) when specific conditions (such as the publishing of new content) are met.
A cache configured for WordPress would delete the cached version of the homepage and archive pages when a single post was published. It would leave all other pages — such as the about page and other posts — untouched since those would not be changed.
Is caching really effective?
We believe that an effective cache setup is the number-one thing websites can do to serve content to visitors as quickly as possible, improve both front-end and back-end load times, and reduce stress on the website’s origin server.
But a well-coded website may already load in as little as two seconds. Isn’t that fast enough? Is caching really worth it? The answer is yes. By using both browser and server caching, you can still save a lot of load times, and, when it comes to loading speed, it pays to make things as fast as possible!
Also worth keeping in mind is that, by implementing caching, you aren’t just making your website faster, you’re also making it perform better — and equipping it to bear the burden of any sudden traffic spikes more efficiently.
Just how effective is caching? According to a recent study by YUI, browser caching can increase speeds by as much as 300%!
Types of Web Caching
There are two types of web-caching: server-side caching and browser-side caching.
- Browser-side caching :
When a web browser displays your webpage it has to load several things like your logo, your CSS file, and other resources.
What browser caching does is « remember » the resources that the browser has already loaded. When a visitor goes to another page on your website your logo, CSS files, etc. do not need to be loaded again, because the browser has them « remembered » (saved). This is the reason that the first view of a web page takes longer than repeat visits.
- Server-side caching
Server-side caching has a similar concept to browser-side caching. The difference that we have is that the server becomes the temporary storage.
Instead of processing every request, the server takes the results of these requests and stores them. It then serves these saved results instead — making everything much faster.
You may have come across the terms ‘object cache’ and ‘full page cache’. These are both server caching methods — the full page cache is what we’ve been talking about so far.
Object caches store only bits and pieces of data, as opposed to a full page. This can be useful within your code, and when storing the result of complex operations such as the generation of a navigation menu.
What Type of Content Can Be Cached?
Although many websites cache primarily to store static objects such as images, modern solutions allow you to cash dynamic content: partially dynamic pages, and even HTML documents, which are the first pieces of information a browser must receive to begin building a web page. Below are three categories of content in relation to caching:
1. Items that are frequently cached:
- Static images
- Logos and brand assets
2.Items that can be cached but are often not:
- HTML documents
- API Calls
3. Files that should not be cached:
- User-specific data such as order history and account information
- Any sensitive data
Of the above, it is the second category which can provide the most improvement in terms of website performance. Caching images and other static objects will certainly speed up page load time, but caching items such as full HTML documents is what can supercharge a website.
HTML documents are especially important, but downloading them can create a blocker for the rest of the pages.
Keeping your website running fast is a key to success – it’s right up there with creating quality content and ensuring airtight security. Fortunately, this isn’t a difficult task if you know what techniques to use.
So If you aren’t already caching your web pages, get to it!