StackPath offers custom query string caching, which allows custom query strings to be specified so that separate versions can be cached based on a unique string.
Previously, all query strings would be cached separately, with no customization offered on this rule. With StackPath’s addition of custom query string caching, specified query strings can be cached individually, while all other unspecified query strings are ignored and cached as the non-query version of the file.
To change the Query String Control setting:
- Log into the StackPath Control Portal.
- Navigate to Sites > Domain > CDN on the left menu bar.
- Under the Cache Handling section, locate the dropdown box for Query String Control.
Ignore Query String - Ignores all query strings, and caches pages as if they have no query strings.
Cache All Query Strings - Caches all query strings separately.
Custom - Allows specific query strings to be entered and cached separately, while all other query strings not listed are ignored.
Adding a Custom Query String
When selecting Custom from the drop-down box, another text field will appear, allowing for the input of the query that will be cached separately. In this example, if different versions of a page are intended to cache separately, then entering "ver" into the custom field will cache all different versions of the file. Clicking the "+" next to the field will add another text field, allowing the addition of more query string parameters to be included.
When the Custom query string control option is selected, "Cache All Query Strings" appears as the selected option. In the example of adding "ver" to the custom parameters field, any version of a page (i.e. ver=1.2, ver=1.5) will be cached individually, allowing end-users to fetch the intended version of a file.
Verifying The Custom Query String
To verify that the custom parameters entered in the custom field are working as intended, a cURL to an asset with two different versions can be performed. StackPath uses cache-key to differentiate cache types. If the rule is working, then the two different file versions will be cached under separate cache keys. Performing the cURL to the URL with -IH "pragma: x-hw-cache-all" appended to the end will result in the CDN cache keys being displayed within the header information:
In the following example, a cURL has been run to a file with two different versions; version 2.2 and version 5.2. Checking the X-HW-Cache-Key will provide us the information needed to check if the files were cached separately:
In the above image, we can see that ver=5.2 is listed in the X-HW-Cache-Key, while below, we can see that ver=2.2 is listed. This verifies that the files are cached separately.
If any further clarification or assistance is needed, feel free to drop us a line at firstname.lastname@example.org, or join us in support chat, we're available 24/7.