We previously went through the fundamentals of caching, what it is, why it’s important for faster web pages, better SEO, and reduced server costs, and what the differences are between a browser cache and a cache installed on a web server. Now we’ll go through some information on what type of content is typically cached, how Content Delivery Networks or CDNs are related to caching, and some tools to cache your own web data and improve the performance of your website.
What web content should I cache for optimal website performance?
There are some types of files that are frequently cached by websites, some files that can be cached but that many websites do not cache because they are seen as “risky” (we’ll get into that later), and others that are never cached.
Files that are frequently cached are ones that are the same for all users and don’t change often. They may include:
- Static images
- Logos and brand assets
- Stylesheets (the code that dictates the font, colors, etc used throughout the website)
- Downloadable files or other content
Files that can be cached but rarely are include:
- Full HTML pages
Files that should not be cached include:
- User-specific data such as account information that is different for each visitor
- Any sensitive data, such as banking or credit card information
Why aren’t HTML pages cached?
The HTML document is the first piece of information that a web browser receives when it loads a web page. This document includes all the information needed to load the elements of a page, including stylesheets (which dictate the colors, fonts, and overall look of a page), logos, images, header and footer files, and more. The process to generate a web page’s HTML document is where most of your server resources are spent, but most CDNs focus on caching static files such as the ones in the above list, and do not cache full HTML documents.
This is because the full HTML document is critical to the look of the web page, and if it is cached incorrectly it could result in a page whose layout appears completely off, or one that displays the wrong user account data. So, despite the considerable speed and resource-freeing benefits, it can be too risky for websites to cache their HTML documents if they aren’t able to properly test their caching configuration and ensure everything will work as expected on the live website. To cache an HTML doc, developers must have the ability to implement flexible configurations within their CDN, and also to test these configurations before they go live. section.io provides these benefits (read more about them in our HTML caching whitepaper), but most CDNs do not allow for flexible configurations and do not have a CDN testing environment. This is the main reason that most sites still direct users back to their servers for the HTML document, slowing down page load time and increasings server costs for the website.
Do I need a CDN to cache my website?
There is an old assumption that the main feature of Content Delivery Networks is to store and delivery static cached content from server locations across the globe, despite that:
Modern CDNs can do much more than cache static objects. You do not actually need a globally distributed server network (CDN) to take advantage of some of the benefits of caching.
Although utilizing a CDN to cache objects can make the process simple, and includes the added benefit of distributed servers to deliver your content to worldwide users, you can install a cache on top of your local server without utilizing a CDN.
What tools are out there for me to cache my web content?
Varnish Cache is a commonly used caching solution which is open-source and can be installed and configured by anyone using Varnish Configuration Language, although complex configurations can still be tricky. Platforms such as Magento, a leading ecommerce software, strongly recommend users implement Varnish Cache for faster page load times. section.io also uses Varnish Cache as our caching layer, and gives users the ability to choose the Varnish version they use and configure it for their application.
How do I quickly set up a cache solution?
section.io makes it easy to install and configure Varnish Cache for your specific application. We let you use the version of Varnish that works best for you, and provide an easy user interface to configure the changes. In addition, section.io provides developer-friendly features not seen in most CDNs, such as a testing environment, the ability to cache full HTML docs, and real-time logs and metrics so you can see what percentage of traffic is hitting the cache and what is going back to your server. Sign up for a free trial today or contact us for a demo and more information on section.io.