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:
www.example.com/product/?id=1&country=us&prodID=1234
www.example.com/product/?id=1&country=us&prodID=7890
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:
www.example.com/product/?id=1&country=us&prodID=1234
www.example.com/product/?id=1&country=us&prodID=7890
Only one version is created: www.example.com/product
/
3. Custom
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:
www.example.com/product/?id=1&country=us&prodID=1234
www.example.com/product/?id=1&country=us&prodID=7890
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 prodID
.
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.