Browser Caching
Browser caching allows your browser to store resource files for a while, so it doesn’t need to retrieve them every time you visit the site.
When you visit a website, you don’t just need to retrieve the content of the page you’re seeing — you also need a bunch of resources such as Javascript files, stylesheets, fonts and so on, which your browser downloads in addition to the content of the page.
The first time you visit this site, for example, you’ll receive a bunch of resources that your browser will immediately cache. This first will likely take a few seconds to completely download, but the next time you visit you’ll notice a significant decrease in load time (as much as a second or more, in fact).
Website caching is one of the most beneficial technologies available. In short, it makes websites extremely fast, which leads to better SEO scores and increased user satisfaction — not to mention better conversions and therefore increased income if you’re selling products or services online.
Websites are generally viewed hundreds, thousands, or sometimes even millions of times per month. Normally, each time a browser requests a web page, the server has to do a bunch of complex (and time consuming) calculations. It retrieves the latest posts, generates the header and footer, finds your site’s sidebar widgets, and so on. However, in many cases, the result of all these calculations will be exactly the same. Wouldn’t it be great, then, if we could simply make the server remember the final result, instead of processing each request separately? This is exactly what caching does!
It’s easiest to understand the caching process by looking at how a page is served. Let’s say you own a blog with caching enabled. The first time someone visits your homepage they receive the page in the normal way: The request is received, processed on the server, and the resulting web page to be shown is turned into an HTML file and sent to the visitor’s web browser.
Since caching is turned on, the server stores this HTML file — usually within its ‘random access memory’ (or RAM), which is extremely fast. The next time you, or anyone else, views the homepage, the server doesn’t need to do the processing and conversion to HTML. Instead, it simply sends the already prepared HTML file to the browser.
That all sounds great, but what if you have caching turned on and then publish a new post? Won’t the new post be outside of the cache and therefore invisible to site visitors? Well, all properly set up caching systems can deal with such scenarios. A caching system doesn’t just consist of the mechanism to store 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.