jiangwenyuan / nuster

A high performance HTTP proxy cache server and RESTful NoSQL cache server based on HAProxy
Other
1.91k stars 157 forks source link

question: how to ignore a specific query parameter for http cache? #113

Closed everyx closed 3 years ago

everyx commented 3 years ago

I use nuster to cache HTTP requests, and I also use Google Ads for marketing, and the problem is visitors from Google Ads will nerver get the cached pages, because when they click the link, Google will add a tracking query parameter to the url: gclid = XXXX. I want them hit the cached pages for more faster loading speed. How can I do this? thank you.

jiangwenyuan commented 3 years ago

Are you able to list all query parameters?

everyx commented 3 years ago

Are you able to list all query parameters?

@jiangwenyuan Google will add a query parameter: gclid=a_long_unique_ID_for_each_user to the end of landing page's url.

For example: I want bring more traffic to my homepage(this is the landing page), and the url is https://www.mydomain.com/, and the traffic from Google Ads's will visit the url https://www.mydomain.com/?gclid=a_long_unique_ID_for_each_user. Then every visitor will never be able to hit the cached pages, even if the content of the page is consistent, because each visitor's gclid value is different, but the query parameter key is always glclid, so I want to find a way to make nuster ignore some query paramater, these paramaters are used as identification only and have no effect on page generation, so remove it is safe for me.

jiangwenyuan commented 3 years ago

@everyx Ah, understood..

Can you try:

http-request set-query %[query,regsub([?&]gclid=[^&]*,gclid=,g)]   
everyx commented 3 years ago

@everyx Ah, understood..

Can you try:

http-request set-query %[query,regsub([?&]gclid=[^&]*,gclid=,g)]   

@jiangwenyuan Thanks, I will have a try, and leave feedback here then :)

everyx commented 3 years ago

@jiangwenyuan Test has been completed, thanks :), I use this as below :

http-request set-query %[query,regsub(\"&?(gclid|wbraid|utm_source|utm_medium|utm_campaign)=[^&]*\",,ig)]