Acting on the Query String
At Transparent Edge, we implement Varnish Enterprise, and therefore you can take advantage of all the benefits it offers.
In this case, we will discuss how to use the urlplus module in Transparent Edge to interact with the query string of a web request.
Normalizing the QS
You may want to normalize the URL, particularly its parameters. For example, the order in which they arrive may be important to increase cache effectiveness, and you may want to ensure that the URL parameters always arrive in the same order regardless of the site from which they are called
In any case, if you don't want to sort it, you just need to do the following:
You must always call the "write" method when working with the urlplus module and you want to modify the URL.
We remove parameters from the QS
Sometimes it may be necessary to remove certain parameters from the query string that arrives at Transparent CDN in order to improve cache effectiveness or simply because we want the URL to be sent to the origin without a specific parameter. One way to do this is as follows, in this case, we are removing a parameter named random:
Removing a parameter from the QS using regex:
Just like the previous example, you may be interested in removing one or multiple parameters from the query string based on a regular expression. For example, we can remove all the parameters added by Google Analytics:
Other functions that can be useful to you are:
query_keep. to remove all the query string except for a specific parameter.
query_get. to retrieve the value of a parameter from the query string.
tolower. to convert the entire URL to lowercase.
toupper. to convert the entire URL to uppercase.
query_add. to add a parameter to the URL.
You can find the complete documentation of this Varnish Enterprise module at the following link.
Last updated