What does it do?
A query string is the part of a URL that comes after a question mark and assigns values to specified parameters.
The correct query string caching behavior results in a better cache hit ratio, which improves site performance.
When and how should I use it?
By default the CDN caches all query strings, but you can change this to suit your website's needs.
There are three options for controlling query strings:
- Cache All Query Strings
The CDN creates a separate cache version, or cache key, for each URL based on the the query string's content. Some examples of this include:
Here, two different cache keys are created.
2. Ignore Query Strings
The CDN ignores the query string (anything after the question mark). Using the same example:
Only one version is created:
This feature allows you to specify the exact query strings that StackPath creates cache keys for. All other query strings are ignored.
For example, if you configure prodID as the custom query string for the following URLs:
StackPath creates two cache keys, one for
prodID=1234 and the other for
prodID=7890. If a user goes to
www.example.com/product/?id=77777&country=canada&prodID=1234, they will get the same content as
www.example.com/product/?id=1&country=us&prodID=1234. Even though some of the query string parameters in this request are different, StackPath won't hit the origin as there is already cached version for
If your site uses specific query strings to show product and content, it is recommended to set the "Query string control" option to "Cache all Query Strings" to ensure that the right content is cached and served to your site's visitors.