Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Varnish Sort Querystring Parameter

Tags:

c

varnish

I've got a lot of requests that avoid caching because all of their list permutations are listed, ie:

http://.....&var=a,b,c
http://.....&var=a,c,b
http://.....&var=b,a,c
http://.....&var=b,c,a
http://.....&var=c,a,b
http://.....&var=c,b,a

Is there a clever way to hash these to the same value? Is the easiest way to sub in the sorted version of the querystring value?

like image 253
Stefan Mai Avatar asked Nov 09 '11 23:11

Stefan Mai


1 Answers

I've written a module for Varnish which reorders the query parameters alphabetically.

Blog post with some explanation:
http://cyberroadie.wordpress.com/2012/01/05/varnish-reordering-query-string/

Code can be found here: https://github.com/cyberroadie/varnish-urlsort

like image 77
Cyberroadie Avatar answered Sep 18 '22 12:09

Cyberroadie