Using a CDN and Front-End Optimization to Boost Website Performance
Using a CDN and Front-End Optimization to Boost Website Performance
If you're looking to boost the speed of your web page by up to 2.5x, consider using both a CDN and front-end optimization.
Join the DZone community and get the full member experience.Join For Free
Sensu is an open source monitoring event pipeline. Try it today.
It’s hardly news that modern business is taking place primarily on the Internet. Regardless of its size, every business will lose some of its power if it doesn’t have an online presence.
The Internet space is large enough to accommodate countless businesses and ventures, but its vast size is not without its obstacles. The challenge here is in gaining a prominent presence for your business without getting lost in the digital crowd; and the only way to ensure this is with superior website performance and a rich and seamless user experience. When you consider that up to 40% of users will abandon a website that fails to load within 2 seconds, optimizing your website becomes not just necessary but imperative.
The image below represents how a browser works:
In general terms, a browser sends a request to the server and renders the requested content once the server responds with the data. The sending and receiving part of the process constitutes the network component, and the content rendering is the front-end component. Optimizing both these components is essential to deliver an enhanced website and this is where content delivery network and front-end optimization (FEO) techniques come into play. The network component can be optimized using CDN while FEO techniques optimize the content.
Today, websites are nothing like what they used to be a few years ago; CSS, JS, and HD images are common in today’s sites and help deliver highly interactive and customized content specific to a user’s browsing habits and geographical location. It’s crucial that such content is delivered as fast as possible – wasted seconds can cost companies in revenue and customer loyalty. CDNs use their highly-distributed platform of servers and advanced infrastructure to not only ensure a smooth operation between a content server and the end users but also to bring the content closer to the user, hence speeding up the process of serving the content. The data below shows the variation in performance when loading content like images, CSS, and scripts from a CDN vs origin servers.
The graph above shows the differences in load time when content is served from a CDN and an origin server. Images and CSS load 2x faster than CDN networks; the content takes around 200ms-1800ms when served from a CDN, while it takes 800ms-4800ms to be served from the origin servers.
Small, medium and large content providers have come to rely on CDN for a seamless web experience for their end users because of its ubiquitous nature that mitigates the challenges encountered when delivering content over the internet.
A lot has been said and written about what a CDN is and why it’s important. You can read more about it here.
Front-End Optimization Techniques
Front-end optimization (FEO) is a service that aims at providing a better user experience with your web content. Also known as content optimization, FEO techniques fine-tune the content on your website by loading it more quickly and making it more browser-friendly.
FEO also compresses file size and minimizes the number of requests required to load the content on the page.
Consider the graph below; it displays the render start time of a website with and without FEO.
As you can see, the render start time improved by 1.5 seconds with the use of FEO techniques.
Benefits of Implementing FEO
1. Compressed files: A website’s content will become lighter and more manageable when the files are compressed. Compressing the files will reduce the total downloaded bytes (page size), which not only saves the bandwidth but also speeds up the download time to load the page faster.
Let’s look at how compression promotes faster page load times. We ran a few tests on a website with file compression both enabled and disabled. After implementing compression, the page size was reduced by 0.5 MB.
Let’s visualize the difference in file size at the request level using waterfall graphs. A difference of 23 – 33% is observed in the file size, which in turn improved the response time of these requests and eventually contributed to a faster download time for the whole page.
Note: We’ve highlighted the identical requests in the above waterfall graphs using unique colors to make it easy to spot the difference in file size and response time.
Fortunately, it is quite easy to enable prefetching. Just add any of these tags within your website’s HTML to enable it –
You can read more about different types of prefetching and the impact it has here.
A larger number of hosts on the page will lead to a higher number of connections. These TCP connections act as a performance overhead which contributes to a slower web page response. Also, you should note that each HTTP request is a unique round trip; the more round trips, the higher the page response time. While some of them may happen in parallel, it can still be a setback to performance.
The screenshot above displays the data for a popular website. The site has only three hosts serving 44 requests on the page, due to which the entire page loaded in less than 2 seconds (web page response: 1738ms) and provided a better user experience.
4. HTML document clean-up: Hypertext Markup Language (HTML) is the building block of most websites and provides a structure to the page including headings, lists, subheadings and other text-organizing features. Web crawlers, which are used by Google to read website pages, make use of HTML when performing web searches. FEO removes unwanted white space and minifies the HTML making it easier to parse and render.
CDN or FEO: Which Is Better?
Recently, we did a CDN performance study for one of the market’s leading Internet security software providers. The study highlighted (as seen below) the performance of the website in three different scenarios – without CDN and FEO, with CDN and FEO and lastly, with CDN and without FEO.
We can see that the there is a great improvement on the site’s page render time (almost 5 seconds faster) when both CDN and FEO techniques are implemented.
So, our answer to the question regarding CDN or FEO: both. CDNs help the FEO processes by streamlining the time needed to perform the task of FEO. For instance, a CDN offers auto minification and auto file compression features that save time, which would otherwise have been spent on manually processing each individual website resource.
Making use of only a CDN without FEO techniques does not necessarily guarantee the best end-user experience for your website. Have you clicked on an image on a website and felt it took forever to load? That is what happens when FEO techniques are not implemented. When files and images are compressed, it enables CDN to work more effectively.
CDNs bring the user closer to resources by handling the performance middle mile. This shortens the number of trips a server makes and results in a faster loading page. FEO techniques, on the other hand, handle the front-end aspect of the website so that the pages run smoothly on a user’s browser.
Simplifying it further, a CDN helps to fetch and load content faster while FEO techniques ensure that the content has been packaged in such a way that it is easier and lighter for the website.
In conclusion, combining CDN and FEO techniques will enable pages to load up to 2.5 times faster, and slash the total payload by a greater extent.
Published at DZone with permission of Alva Yashaswi , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.