Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Google Analytics use some query parameters to identify campaigns and to do cookie control. This is all handled by javascript code. Take a look at the following example:

http://www.example.com/?utm_source=newsletter&utm_medium=email&utm_ter m=October%2B2008&utm_campaign=promotion

This will set cookies via JavaScript with the right campaign origin. This query parameters can have multiple and sometimes random values. Since they are used as cache hash keys the cache performance is heavily degraded in some scenarios.

I suppose there's a not so hard configuration on cache servers to just ignore all query parameters or specific query parameters. Am I right?

Does anyone know how hard is it in popular web cache solutions, to create ?

I'm not interested in a specific web cache solution. It would be great to hear about the one you use.

share|improve this question

3 Answers 3

Fiddling with the cache is not the right way to go about this.

The "right" way to handle URLs with this sort of tracking is to send a 301 redirect to your canonical URL (after actually doing any necessary tracking, of course).

share|improve this answer

In varnish, in the vcl_recv function

set req.url = regsub(req.url, "\?.*", "");

You would really need to evaluate whether you wanted to do that though. If it is served from Varnish rather than your backend, are you altering any of your stat collection processes?

share|improve this answer
1  
Just removing all utm_ parameters -- [?&]utm_[a-z]*=[^&]* (or something similar) -- might be better than removing all of them. Having example.com/?page=this and example.com/?page=that cached as the same entity can cause headache. –  grawity Sep 11 '10 at 15:20

Not sure I entirely follow you, but:

With squid I believe you would create a url regex ACL and then use the cache directive to tell it not to cache those requests.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.