Fastly ignore certain query strings containing campaign tracking data
The information in this post is accurate as of the published date . Please make sure to check any linked documentation within the post for changes/updates.
Hi Team,
We need to ignore certain query strings containing campaign tracking data on Fastly.
An example: ‘set req.url = querystring.regfilter(req.url,“utm_|_hsenc|_hsmi|hsCtaTracking”)’;
I Created custom VCL for that on staging branch. it gives below output.
curl -i “https://api.fastly.com/service/$FASTLY_SERVICE_ID/version/1/vcl” -H “Fastly-Key: $FASTLY_API_TOKEN” -H “Accept: application/json”
HTTP/2 200
status: 200 OK
cache-control: no-store
content-type: application/json
accept-ranges: bytes
via: 1.1 varnish, 1.1 varnish
date: Sat, 01 Jul 2023 08:57:55 GMT
x-served-by: cache-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-bom4736-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1688201875.957649,VS0,VE259
vary: Accept-Encoding
strict-transport-security: max-age=31536000
content-length: 274
[{“deleted_at”:null,“updated_at”:“2023-06-30T10:18:03Z”,“version”:1,“name”:“requesturi-vcl”,“service_id”:“SERVICE_ID”,“content”:“set req.url = querystring.regfilter(req.url,"utm_|_hsenc|_hsmi|hsCtaTracking");”,“main”:false,“created_at”:“2023-06-30T10:18:03Z”}]%
Please guide what else changes required here for VCL. As per documentation created VCL and hit command for get VCL and it gives output above. Is there any version issue? What version i can apply?
Regards,
Piyush Raval
-
Hi,
Fastly works with versions. Each configuration change you make will need to happen on a copy of the current version, and then, the new version can be activated.
mkdir normalizing_requests_for_better_cache_performance cd normalizing_requests_for_better_cache_performance
create snippet:
export FASTLY_SERVICE_ID=[YOUR_SERVICE_ID] fastly vcl snippet create --name=snippet_init --type=init --content="$(cat init.snippet)" --version=latest --autoclone fastly vcl snippet create --name=snippet_recv --type=recv --content="$(recv.snippet)" --version=latest --autoclone
Activate:
fastly service-version activate --version=latest
0
Please sign in to leave a comment.
Comments
1 comment