Query String Sort allows customers to increase cache hits on resources with varied query strings.
Overview
By default, Cloudflare’s cache treats resources as distinct if their URL query strings are in a different order. For instance, these resources are cached separately:
/video/48088296?title=0&byline=0&portrait=0&color=51a516
/video/48088296?byline=0&color=51a516&portrait=0&title=0
Query String Sort increases cache-hit rates by first sorting query strings into a consistent order before checking the Cloudflare cache. If two query strings exist with the same name, the URL is sorted by the parameter value. For example:
/example/file?word=alpha&word=beta
and
/example/file?word=beta&word=alpha
are sorted to:
/example/file?word=alpha&word=beta
Enable Query String Sort
Query String Sort is available in the Cloudflare dashboard under the Caching app.
- Log into your Cloudflare account.
- Choose the appropriate domain for which you want to enable Query String Sort.
- Click the Caching app.
- Scroll down to Enable Query String Sort
Toggle the switch to On.