caching - Ignore utm_* values with varnish? -


Can I ignore query string variables by dragging the matched object from the cache, but can not really remove them from the URL last -the user?

For example, all marketing utm_source , utm_campaign , utm _ * does not change the contents of the page, They differ greatly in the campaign from the campaign and are used by all of our customer-side tracking.

Therefore it also means that the URL can not be changed in the customer side, but it should be 'normalized' in some way in the cache.

Basically I want all these ...

http://example.com/page/?utm_source=

/ example .com / page /? Utm_campaign = usa

... http://example.com/page/

to use all

However, this URL will be the cause of a mis (because the ultimate one is not utm_ * param)

http://example.com/page/?utm_source=google&variation=5

will trigger the cache

http://example.com/page/?variation=5

Also, keeping in mind that the URL to be seen in the URL should be the same, I redirec Can not do without parameters or any kind of solution such as

Then I will add a disclaimer that this regex is probably not correct, but it works very well Required:

  sub vcl_recv {set req.url = regsuball (req.url, "\ (utm _ [^ = & amp;] * = [^ & amp;; Amp; =] * & amp; ;?) + ","? "); Set req.url = regsuball (req.url, "& amp; (utm _ [^ = & amp;] * = [^ & amp; =] * (& amp; |)) +", "\ 2" ); Set req.url = regsub (req.url, "\? $", ""); Return (pass); }  

Should remove any query parameter starting with utm _ . I used three regexs to make it clear and easy to read in the beginning of the query string.

Delete any utm _ parameter before regsuball . This ? Looks for one or more utm _ parameters immediately after . The second regsuball is any utm _ parameter which does not delete the start of the query string.

The third regex will remove the URL and clear the URL ? If there is no query parameter, then we have left after the utm _ parameter has been removed. Both regexes should be in () + < as it will match one or more consecutive utm _ parameters (they will not match otherwise).

Example results:

  Source URL: / utm_track = 1 & amp; Utm_test2 = O & amp; Test = utm_blah & amp; Utm_source = google & amp; Variation = 5 & amp; Utm_query = ABC & amp; Utm_test7 = Yes in the map ?? / Test = utm_blah & amp; Variation = 5 Source URL: / Variation = 5 & amp; Utm_test1 = ABC & amp; Utm_test2 = Def & amp; Blah = 1 in the map: / variety = 5 and blah = 1  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -