Call usTry Fastly free

Using Boltsort to Make API Caching More Efficient


If you're caching (parts of) an API that is consumed by various developers, you might find that they all have different ideas about the order in which the arguments are placed in the query string. The following URLs should all be considered the exact same by your origin:

And that's with just 3 parameters!

There's a Fastly module available called "boltsort" which allows you to easily sort the parameters in the query string, so that you will always end up with the same URL, no matter what order the consumer of your API placed them in.

Using it couldn't be simpler:

# at the top of your VCL
import boltsort;


sub vcl_recv {
  set req.url = boltsort.sort(req.url);

Of course not all variations will be used, but the amount of requests to your origin could decrease significantly.

Share this post