Dynamic Site Acceleration
We've written a post in the past about static site hosting with a CDN, but what about dynamic site acceleration? CDNs are traditionally used to cache and deliver static content as this type of content does not change very often. This allows users to receive the most updated version of a particular static file much faster. However, the caching requirements for dynamic content can be much different.
This post will help explain the differences that exist between dynamic and static content as well as what options you have when looking to perform dynamic site acceleration.
Dynamic vs static content
The main difference between dynamic and static content is that dynamic content changes while static content stays the same. Take for example a CSS or JS file, these types of assets rarely change unless someone modifies the file directly. This type of content is easily cacheable as it allows the caching servers (such as a CDN) to store these files for extended periods of time without checking the origin server. This helps decrease load time and improve efficiency.
Dynamic content on the other hand, changes frequently. Take for example a social platform or an online ecommerce store. With social platforms statuses, comments, etc are constantly being updated to display the most recently posted content. Similarly, with ecommerce shops, the stock of an item must be dynamically displayed to show the number of items left for a particular product. Dynamic content is often produced with the help of a server side language and database.
The image above shows a visual comparison between a static and dynamic website. As you can see, the static website does not require any calls to a database, it simply fetches all of the static content from the server and then is delivered directly to the client. Dynamic websites however, must perform database queries in order to gather the appropriate information before delivering the website's content to the client.
How to perform dynamic site acceleration?
Using a CDN, there are a few ways to perform dynamic site acceleration. KeyCDN offers three options for caching CDN dynamic content. Each option takes advantages of caching and purging capabilities as defined within your KeyCDN dashboard or web application.
- API purging - The KeyCDN API can be utilized directly from within your web application to intelligently purge the cache for a specific Zone/URL based on a user or server-based action. With this properly configured within your application, the API will automatically purge the specified content at any given time, instantly. This allows your visitors to see the most recently updated content instead of being delivered previously cached content that may no longer be applicable or recent.
- Leverage browser caching - KeyCDN users can also specify a custom value for the
Cache-Controlresponse header fields. Modifying this value specifies how long a cached copy of an asset will remain in the user's browser cache. This value overwrites what is received from the origin and only affects the browser cache, not the KeyCDN edge server cache.
If you are looking to perform a dynamic site acceleration, as you can see by the options above it is possible. It requires some configuration on the part of the website developer/maintainer, however may be worth the effort depending on your use case. KeyCDN makes it easy to instantly purge your assets using a couple of different methods and when accelerating dynamic content, being able to control when and what to purge is an extremely important feature to have.