The StackPath CDN comes with a predefined configuration that will accelerate the delivery of your site. This page provides the best practices for optimizing and accelerating the site delivery even more and getting the best out of StackPath CDN.
Setting Expiration Time
Setting the expiration time for assets cached on the CDN (“Lifetime") will reduce the number of calls to your server and will increase the number of time assets are being served from cache.
You can set the CDN to honor your origin headers (which will instruct the CDN if to cache an asset or not and for how long) or set it to “Specify CDN TTL” with the needed expiration time.
It is important to set an expiration time for your specific use case, some examples:
- Logo, images, CSS or JS files can have a high TTL time
- Pages who update frequently will have a shorter TTL time
You can also customize the TTL for specific pages and file extensions using the EdgeRules.
For more information on CDN Life Time, please feel free to check out this article!
Setting up Correct Query String Behavior
A query string is a string of text that is added to the URL of a request to modify behavior on the server, allowing for different content to be served to different clients or users based on how the request originated.
A common example would be adding a query string to tell the server that a link was clicked from within a "Members Only" area of a site, or perhaps adding a query string to based on the region or locale of the user to serve location-specific content.
Setting up the correct query string caching behavior will result in a better cache hit ratio which will improve performance. There are 3 options for the query string control:
- Cache All Query Strings - The CDN will create a cache key for each URL based on the specific query strings, so for example, for the following URLs:
Two different cache keys (cache versions) will be created.
- Ignore Query Strings - The CDN will ignore the query strings (anything after the ? sign), so for example, for the following URLs:
Only one version will be created:
- Custom - This Feature allows you to specify the exact query strings we'll create cache keys for, all other query strings will be ignored. So for example, if you'll configure
prodIdas the custom query string, for the following URLs:
We will create 2 cache keys. one for
prodID=1234and the other for
That also means that if I'll browse to:
I will get the same content as for
In this request, even though some of the Query String parameters are different we won't hit the origin as we already have a cached version for prodID.
For more information on query string caching, please feel free to check out this article in our knowledge base!
Browser Cache TTL
Browser cache TTL is the time that StackPath will instruct the visitor’s browser to cache a resource. The browser will load resources from its local cache until that time is expired.
A high browser cache TTL will accelerate the website page loads for your repeat visitors.
You can find more information on the Browser Cache TTL Settings in this article from our Knowledge Base!
GZIP is a method of compressing files (making the files smaller) which will result in faster network transfers.
Enabling GZIP compression is a standard practice to provide smaller file sizes which will load faster for your website users. The recommended compression level is 6.
For more information on using GZIP compression, please feel free to read this article.
Running Speed Tests
There are multiple tools such as that allows you to test your site loading time from various locations. A good practice is to test your site before adding the CDN into the mix, then again after. Some popular options are:
Please note that speed tests do carry variables that might show your speed being higher than you might expect. You may need to run a test 2-3 times to make sure the test is getting your site from the StackPath CDN cache before seeing the results in the score you receive.
These tests, while a good general guide, are often not completely reflective of the user-experience as they often times will show a speed that is slightly slower than what you might experience using your browser's load-time metrics.
Tests like these are that they often highlight things you can improve and optimize on your server or in your site's code for an even better user experience.
Migrating your DNS to StackPath
StackPath offers DNS service as well, it's easy to set up and will help you be able to manage all your stuff in one place. Feel free to check out some of our articles below on our DNS service and how to easily move your DNS records over to StackPath:
- How do I find the StackPath Name Servers
- Setting up StackPath DNS
- How To Import A DNS Zone File
- Creating DNS Records
- What DNS record types does StackPath support
As always, If you have any questions or concerns about any of the topics mentioned in this article, please feel free to reach out to support - we are available 24/7 by chat or email!